C# 获取当前路径 (exe、dll)
c# 获取 路径 当前 dll exe
2023-09-11 14:15:06 时间
//获取模块的完整路径。 string path1 = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; //获取和设置当前目录(该进程从中启动的目录)的完全限定目录 string path2 = System.Environment.CurrentDirectory; //获取应用程序的当前工作目录 string path3 = System.IO.Directory.GetCurrentDirectory(); //获取程序的基目录 string path4 = System.AppDomain.CurrentDomain.BaseDirectory; //获取和设置包括该应用程序的目录的名称 string path5 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //获取启动了应用程序的可执行文件的路径 string path6 = System.Windows.Forms.Application.StartupPath; //获取启动了应用程序的可执行文件的路径及文件名 string path7 = System.Windows.Forms.Application.ExecutablePath;
string path8 = System.Reflection.Assembly.GetExecutingAssembly().Location; string path9 = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
前7种获取的都是exe所在目录,后两种获取的是dll所在目录
public static string AssemblyDirectory { get { string codeBase = Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); return Path.GetDirectoryName(path); } }
相关文章
- C# 获取USB设备信息
- C# .net中获取台式电脑中串口设备的名称
- json字符串生成C#实体类的工具
- C#基础视频教程7.4 如何编写简单游戏
- C#开发可以可视化操作的windows服务
- 使用C#获取CPU及硬盘序列号的源代码
- C#获取当前路径方法
- C# DataSet.RejectChanges 方法
- C# 容器上控件排序
- C# 中winform的一些属性设置
- C# 获取Excel工作薄中Sheet页(工作表)名集合
- Atitit.获取approot api 应用根路径 java c#.net php asp
- Atitit,通过pid获取进程文件路径 java php c#.net版本大总结
- Atitit,通过pid获取进程文件路径 java php c#.net版本大总结
- (八十)c#Winform自定义控件-分割线标签-HZHControls
- c# 获取cook
- C#使用System.IO.Path获取文件路径、文件名
- 使用C#对MongoDB中的数据进行查询,改动等操作
- C#获取特定进程CPU和内存使用率
- C# BeginInvoke EndInvoke获取返回值
- c# 获取相对路径
- C#获取当前路径的7种方法
- C# 获取当前方法的名称空间、类名和方法名称
- [C#]c#中数据的同步加锁机制 的几种方法