1. Path-related
Path operation: using the path class, you can directly obtain the complete path, path, file name, extension, and file name without extension.
Special path selection:
Environment. currentdirectory // current path
Environment. specialfolder. desktop; // desktop path
2. Environment class
Attribute:
Tickcount
Obtain the number of milliseconds after the system is started.
CommandLine obtains the command line of the process.
Currentdirectory gets and sets the full path of the current directory (that is, the directory from which the process starts.
Specialfolder. Various special paths, such as desktop, ie cache, application data, and personal
Exitcode gets or sets process exitCode.
Machinename: Obtain the NetBIOS Name of the local computer.
Newline gets the newline string defined for this environment.
Processorcount gets the number of processors on the current computer.
Systemdirectory gets the fully qualified path of the system directory.
Get a version object that describes the main version, next version, internal version, and revision number of the common language runtime.
Workingset obtains the amount of physical memory mapped to the process context.
Method:
Exit terminates the process and provides the specified exit code for the basic operating system.
Getcommandlineargs returns a string array containing the command line parameters of the current process.
Getfolderpath gets the path pointing to the system special folder identified by the specified enumeration.
Getlogicaldrives returns a string array containing the name of the logical drive on the current computer.
Getenvironmentvariable is overloaded. Returns the value of an environment variable.
Setenvironmentvariable is overloaded. Create, modify, or delete environment variables.
Getenvironmentvariables is overloaded. Retrieve the names and values of all environment variables.
Reference: http://msdn.microsoft.com/zh-cn/library/system.environment_members%28v=VS.80%29.aspx
3. Judge string comparison
Public static int compare (string stra, string strb [, bool ignorcase]); // string. Compare (string a, string B, false );
Public int compareto (string strb );
Public bool equals (string value); instance call, case sensitive
Public static bool equals (string a, string B); Class call
Whether the string is null:
If (textbox4.text = string. Empty) "" can also
4. type conversion
Extract an integer from a string: int year = int32.parse (STR); // extract an integer from a string
5. Call the systemProgramOpen a specified file
Using system. diagnostics;
System. diagnostics. process. start (string filename); // open the specified file. The system calls the associated program system. diagnostics. process. start ("C: // program files // fetion // fetion.exe"); // open the program
Process. Start ("http://www.baidu.com"); // open the page
Process. Start ("iexplore.exe"); // open IE, default homepage
Process. Start (environment. getfolderpath (environment. specialfolder. favorites); // open the favarites folder
Process. Start ("iexplore.exe", "www.northwindtraders.com"); // with parameter 1
Process. Start ("iexplore.exe", "C: // mypath // myfile.htm"); // parameter 2
Processstartinfo startinfo = new processstartinfo ("ipolice.exe"); // startupinfo
Startinfo. windowstyle = processwindowstyle. minimized;
Process. Start (startinfo );
Startinfo. Arguments = "www.northwindtraders.com ";
Process. Start (startinfo );
Reference: http://msdn.microsoft.com/zh-cn/library/system.diagnostics.process.aspx
6. Exit the program
Environment. Exit (1 );
Application. Exit ();
7. Process Traversal
(1) foreach (Process in processes)
(2) Using system. diagnostics;
Process [] process = process. getprocesses ();
VaR P = (from proc in process
Where Proc. processname. Equals ("Explorer ")
Select proc). firstordefault ();
P. Kill (); close the process
(3)
Private void button#click (Object sender, eventargs e) <br/>{< br/> string STR = ""; <br/> process [] processes = process. getprocesses (); <br/> MessageBox. show (processes. length. tostring (); <br/> for (INT I = 0; I <processes. length; I ++) <br/>{< br/> If (string. compare (processes [I]. processname, "Explorer", false) = 0) <br/>{< br/> MessageBox. show ("I am Explorer"); <br/> processes [I]. kill (); // terminate the process <br/>}< br/> STR + = processes [I]. processname + "/N"; <br/>}< br/> MessageBox. show (STR); <br/>}
Custom Message Processing
Look at: http://blog.csdn.net/jiutao_tang/archive/2011/06/20/6555779.aspx
Toolstripmenuitem menuitem1 = new toolstripmenuitem ("open ");
File toolstripmenuitem. dropdownitems. insert (0, menuitem1 );
Menuitem1.click + = new eventhandler (Open toolstripmenuitem_click); // specify the Click Event
Click Event:
Private void open toolstripmenuitem_click (Object sender, eventargs e ){
Openfiledialog1.filter = "all files (*. *) | *.*";
If (openfiledialog1.showdialog () = dialogresult. OK ){
}
}