C# 获取当前路径

        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);
            }
        }

 

 

//获取当前dll 所在目录
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

 
 
// 获取程序的基目录。
System.AppDomain.CurrentDomain.BaseDirectory
 F:\广告编辑系统新\taxi_edit\taxi_form\bin\Debug\

// 获取模块的完整路径。
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
 F:\广告编辑系统新\taxi_edit\taxi_form\bin\Debug\taxi_form.vshost.exe

// 获取和设置当前目录(该进程从中启动的目录)的完全限定目录。
System.Environment.CurrentDirectory
 F:\广告编辑系统新\taxi_edit\taxi_form\bin\Debug

// 获取应用程序的当前工作目录。
System.IO.Directory.GetCurrentDirectory() 
 F:\广告编辑系统新\taxi_edit\taxi_form\bin\Debug

// 获取和设置包括该应用程序的目录的名称。
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase
F:\广告编辑系统新\taxi_edit\taxi_form\bin\Debug\
// 获取启动了应用程序的可执行文件的路径。
System.Windows.Forms.Application.StartupPath 
F:\广告编辑系统新\taxi_edit\taxi_form\bin\Debug
// 获取启动了应用程序的可执行文件的路径及文件名
System.Windows.Forms.Application.ExecutablePath
F:\广告编辑系统新\taxi_edit\taxi_form\bin\Debug\taxi_form.EXE
 
获得当前起作用的配置文件
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
 
 
posted on 2016-01-11 17:30  苏上话  阅读(204)  评论(0)    收藏  举报