Use Visual C # To clear the recycle bin (2 ),
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; // The namespace class Recycle {public static void Main () {int c = 0 used in the import program; // define this variable to determine whether the file foreach (string s1 in Directory) exists in the Directory. getFiles ("c: \ recycled") // returns the enumerated type {++ c;} if (c> 0) of the string row of the file name) // determine whether a file exists. If c> 0, the recycle bin has a file. Otherwise, no {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) // press the OK button {foreach (string s in Directory. getFiles ("c: \ recycled") // put the full path name 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.