C#获取当前路径
使用 AppDomain.CurrentDomain.BaseDirectory
这种方法适用于大多数情况,返回包含应用程序的目录
using System;
class Program
{
    static void Main()
    {
        string path = AppDomain.CurrentDomain.BaseDirectory;
        Console.WriteLine(path);
    }
}获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称,适用于 Windows Forms。
private void PrintStartupPath()
{
   MessageBox.Show( "The path for the executable file that " +
      "started the application is: " +
      Application.StartupPath);
}获取启动了应用程序的可执行文件的路径,包括可执行文件的名称,适用于 Windows Forms。
private void PrintStartupPath()
{
   MessageBox.Show( "The path for the executable file that " +
      "started the application is: " +
      Application.ExecutablePath);
}扫描二维码推送至手机访问


