Winform中的相对路径

string   path   =   System.IO.Directory.GetCurrentDirectory();//获取应用程序的当前工作目录。  
  string   str1   =   Application.StartupPath;//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称  
  string   str2   =   Application.ExecutablePath;//获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。  
  string   str3   =   Environment.CurrentDirectory;//获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。  
   
  System.Reflection.Assembly   ass=   System.Reflection.Assembly.GetExecutingAssembly();//获取当前代码正从中运行的   Assembly  
  string   strConfigLoc=ass.Location;//如果包含清单的已加载文件没有被影像复制,则获取该文件的基本代码格式的位置  
  FileInfo   FileInfoObj=   new   FileInfo(strConfigLoc);  
  strConfigLoc=FileInfoObj.DirectoryName;  
  MessageBox.Show(strConfigLoc);  

转载于:https://www.cnblogs.com/baishiying/archive/2012/09/17/2688668.html

猜你喜欢

转载自blog.csdn.net/weixin_34375233/article/details/93439980