C#获取常用的路径

常用的这两个足够了,其他需要的自行百度
//获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。
string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)

//获取和设置包含该应用程序的目录的名称。(推荐) string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; result: X:\xxx\xxx\ (.exe文件所在的目录+"\")


猜你喜欢

转载自www.cnblogs.com/within-pro/p/10482871.html