1. Directory Class
Create a folder Directory.CreateDirectory
Delete Folder Directory.delete
Move Folder Directory.move
Get the path to all files in the folder string[] path = Directory.GetFiles (@ "C:\Users\Administrator\images", "*.jpg");
Get the path to all folders within the folder string[] Dirpath = directory.getdirectories (@ "C:\Users\Administrator");
Whether the folder exists Directory.exist (@ "C:\Users\Administrator\images")
2. WebBrowser control
Property URL:
string text = TextBox1.Text;
Uri uri = new uri ("http://" + text);
Webbrowser1.url = URI;
3. ComboBox Drop-down Box control
Name: cbo+ ...
Case: Date Selector
Property DropDownStyle: Controls the style of the Drop-down box--dropdownlist
Combobox.selecteditem
Event SelectedIndexChanged
4. ListBox List Control
Case: Click to change Picture
1 loading the file name of the specified picture into the listbox when the program is loaded
2 in the DoubleClick () event of the ListBox, place the corresponding picture in the PictureBox
5. The SoundPlayer class function is to play. wav files
SoundPlayer sp = new SoundPlayer ();
Sp. Soundlocation = Path[listbox1.selectedindex];
Sp. Play ();
6. Stone Scissors Cloth
WinForm is used in conjunction with object-oriented methods
Stone 1 Scissors 2 cloth 3
The player wins 1-2=-1 2-3=-1 3-1=2
Draw Subtract =0
Another situation: The computer won the 1-3=-2 2-1=1 3-2=1
7. dialog box
1 Open File dialog box OpenFileDialog
Property. Title. MultiSelect. InitialDirectory. Filter
. FileName takes the full path to the file in the Open File dialog box
method. ShowDialog ()
2 Save File dialog box SaveFileDialog
3 Font dialog Box FontDialog
4) Color dialog box ColorDialog
8. Menu--menustrip
9. Single thread brings us the problem (multithreading benefits)
1 Let the computer "at the same time" more than one thing, save time
2 multithreading allows a program to "simultaneously" handle multiple things
3 running the program in the background to improve the operation efficiency of the program, will not cause no response to the main interface
Four steps to produce a thread
1 Write the method that produces the thread to execute
2) Introduction of System.Threading namespaces
3 instantiate the thread class and pass in a delegate that points to the method that the thread will run
(This thread has already been generated, but it has not yet run)
Thread th = new Thread (Test);
4 invokes the Start method of the thread instance, marking that the thread can be executed by the CPU, but the specific execution time is determined by the CPU
Th. Start ();
10. Foreground threads and background threads
The default is foreground thread, foreground thread: Only all foreground threads are closed to complete the program shutdown
Background thread: The background thread automatically ends as soon as all foreground threads are finished. Th. IsBackground = true;
11. Under. NET, cross-thread access is not allowed
To cancel a cross-thread access check Contorl class is the base class for all controls in WinForm
Form1_Load when a program is loaded
Control.checkforillegalcrossthreadcalls = false;
. Th. Abort () is the terminating thread and cannot be th at start () after termination is complete. Sleep (3000) can cause the current thread to stop for a period of time
&NBSP
13. Process
class process
There are some static methods:
Open Some applications through the process Process.Start ("Calc")
Open the specified file through a process
class ProcessStartInfo
processstartinfo psi = new ProcessStartInfo (@ ". exe");
process p = new Process ();
p.startinfo = psi;
p.start ()