获取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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM