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

posted on 2012-09-17 14:18  the Jade Emperor  阅读(202)  评论(0编辑  收藏  举报

导航