获取Windows服务下当前路径的方法
获取Windows服务下当前路径的方法
获取当前运行程序路径 包含exe
Assembly.GetExecutingAssembly().Location;
D:\xxxxxx\bin\Debug\xx.exe
获取当前运行程序路径 包含exe
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
D:\xxxxxx\bin\Debug\xx.exe
获取该进程从中启动的目录
System.Environment.CurrentDirectory;
C:\WINDOWS\system32\Logs
获取应用程序的当前工作目录
System.IO.Directory.GetCurrentDirectory();
C:\WINDOWS\system32
获取程序的基目录
System.AppDomain.CurrentDomain.BaseDirectory;
D:\xxxxxx\bin\Debug
获取启动了应用程序的可执行文件的路径
System.Windows.Forms.Application.StartupPath;
D:\xxxxxx\bin\Debug