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