The relative path Winform

string path = System.IO.Directory.GetCurrentDirectory (); // Get the current working directory of the application.  
  string str1 = Application.StartupPath; // get the path to start the application's executable file, the name of the executable file does not include the  
  string str2 = Application.ExecutablePath; // get the path to start the application's executable file, including name of the executable file.  
  string str3 = Environment.CurrentDirectory; // get and set the current directory (i.e., the process from startup directory) fully qualified path.  
   
  System.Reflection.Assembly ass = System.Reflection.Assembly.GetExecutingAssembly (); // Get the current Assembly code is being run from a  
  string strConfigLoc = ass.Location; // If you include a list of the loaded image files are not copied, then get the basic position of the code format file  
  the FileInfo FileInfoObj the FileInfo new new = (strConfigLoc);  
  strConfigLoc = FileInfoObj.DirectoryName;  
  MessageBox.Show (strConfigLoc);  

Reproduced in: https: //www.cnblogs.com/baishiying/archive/2012/09/17/2688668.html

Guess you like

Origin blog.csdn.net/weixin_34375233/article/details/93439980