First, get the path where the execution program is located
1. Gets and sets the fully qualified path to the current directory.
string str = System.Environment.CurrentDirectory;
Result:c:\xxx\xxx
2. Gets the path to the executable file that launched the application, not including the name of the executable file.
string str = System.Windows.Forms.Application.StartupPath;
Result:c:\xxx\xxx
3. Gets the full path of the new process component and associates it with the main module associated with the currently active process, including the file name.
String str = System.Diagnostics.Process.GetCurrentProcess (). Mainmodule.filename;
Result:c:\xxx\xxx\xxx.exe
4. Gets the base directory of the current application domain for Thread, which is used by the Assembly resolver to probe assemblies.
string str = System.AppDomain.CurrentDomain.BaseDirectory;
Result:c:\xxx\xxx\
5. Get the current working directory of the application.
String str = System.IO.Directory.GetCurrentDirectory ();
Result:c:\xxx\xxx
6. Gets and sets the name of the directory that contains the application.
string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
Result:c:\xxx\xxx\
7. Gets the full path of the current process, including the file name.
String str = this. GetType (). Assembly.location;
Result:c:\xxx\xxx\xxx.exe
8. Get the path to the executable file that launched the application, including the name of the executable file. string str = System.Windows.Forms.Application.ExecutablePath;
Result:c:\xxx\xxx\xxx.exe
In addition, see Configuring Specific paths through XML files to achieve a reasonable location for planning configuration files, such as paths in configuration files in the Web.
Second, start the Resource manager: System.Diagnostics.Process.Start ("Explorer.exe", Globalinfos.classroomrecordpath);
1. Direct start ProcessStartInfo Info=NewProcessStartInfo (); Info. FileName= Path.Combine (Environment.getenvironmentvariable ("windir"),"Explorer.exe"); Process.Start (info). WaitForExit (); 2. Similar to 1ProcessStartInfo info=NewProcessStartInfo (); info. CreateNoWindow=true; info. UseShellExecute=true; info. WindowStyle=Processwindowstyle.hidden;info. FileName= Path.Combine (Environment.getenvironmentvariable ("windir"),"Explorer.exe"); Process.Start (info); 3. Shell external MethodsPrivate voidButton1_Click (Objectsender, EventArgs e) {ShellExecute (IntPtr.Zero,NULL,"Explorer.exe",NULL,NULL, showcommands.sw_show); } Public enumShowcommands:int{sw_hide=0, SW_SHOWNORMAL=1, Sw_normal=1, sw_showminimized=2, sw_showmaximized=3, Sw_maximize=3, Sw_shownoactivate=4, Sw_show=5, Sw_minimize=6, Sw_showminnoactive=7, Sw_showna=8, Sw_restore=9, Sw_showdefault=Ten, Sw_forceminimize= One, Sw_max= One} [DllImport ("Shell32.dll")] Static externIntPtr ShellExecute (IntPtr hwnd,stringLpoperation,stringLpfile,stringLpparameters,stringlpdirectory, Showcommands nshowcmd); 4. Shell Window General Process.Start (Path.Combine (environment.getenvironmentvariable ("windir"),"Explorer.exe")); Shellwindows win=Newshdocvw.shellwindows (); 5The . cmd command executes the explorer.exeSystem.Diagnostics.Process Process=NewSystem.Diagnostics.Process (); System.Diagnostics.ProcessStartInfo StartInfo=NewSystem.Diagnostics.ProcessStartInfo (); Startinfo.windowstyle=System.Diagnostics.ProcessWindowStyle.Hidden; Startinfo.filename="Cmd.exe"; Process. StartInfo=StartInfo; Process. Startinfo.redirectstandardinput=true; Process. Startinfo.redirectstandardoutput=true; Process. Startinfo.useshellexecute=false; Process. Start (); Process. Standardinput.writeline (Environment.getenvironmentvariable ("windir")+"\\explorer.exe"); Process. Standardinput.flush (); Process. Standardinput.close (); Process. WaitForExit ();
View Code
C #: Get the path where the executable is located and start the resource Manager