4. program source code (recycled. cs), compilation method, and running interface:
(1). Source Code of the program: recycled. cs:
Using System. IO; Using System. Windows. Forms; // namespace used in the import program Class Recycle { Public static void Main () { Int c = 0; // defines this variable to determine whether a file exists in the directory. Foreach (string s1 in Directory. GetFiles ("c: \ recycled") // return the enumerated type of the row with the file name string. { ++ C; } If (c> 0) // determines whether a file exists. if c> 0, the recycle bin has a file, and vice versa. { DialogResult r = MessageBox. Show ("are you sure you want? "," Garbage disposal! ", MessageBoxButtons. YesNo, MessageBoxIcon. Question ); // Display the "OK" and "cancel" buttons. the icon is displayed as a question mark. Int ss = (int) r; If (ss = 6) // click the OK button {Foreach (string s in Directory. GetFiles ("c: \ recycled ")) // Name the whole path in house s { File. Delete (s); // Delete this File } } } } } |
(2). Compilation Method:
After compiling through the following command line, a Windows execution file is generated: recycled.exe.
Csc/t: winexe/r: system. dll/r: system. windows. forms. dll recycled. cs
Run this file to obtain the following execution interface:
Figure 01: Program Execution Interface |
V. Summary:
This article describes the powerful functions of Visual C # In File Processing through a software manufacturing process, in fact, what we described above is only a small Application of Visual C # In File Processing. In addition, Visual C # has powerful functions in other aspects. Yes. the powerful backing of the Net FrameWork SDK, Visual C # makes the difficult problem to be handled in the previous program relatively simple, and makes it possible to solve the problem that was originally impossible, this is why Visual C # becomes the next-generation mainstream programming language.