编程很好玩!
编程很好玩!

导航

 

//获取应用程序的当前工作目录。

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 2010-02-05 15:59  lzp  阅读(670)  评论(0编辑  收藏  举报