Use Visual C # to empty the recycle bin (2)

zhaozj2021-02-16  68

Keywords .NET C # Source http://www.yesky.com/20011116/205481_1.shtml

IV. Program source code (Recycled.cs), compilation method and running interface:

(1). Program source code: Recycled.cs:

Using system.io; using system.windows.forms; // Name space used in the import program Class Recycle {public static void main () {int C = 0; // Define this variable is mainly to determine if there is in the directory File Foreach (String S1 in Directory.GetFiles) / / Returns the enumeration type { C;} if (c> 0) // determines if the file name // If c> 0 recycles station with files, there is no {DialogResult r = messagebox.show ("Is it sure?", "Garbage handling!", Messageboxbuttons.yesno, messagingBoxicon.question; // Display "OK" and " Cancel "two buttons, the icon display is a question mark. INT SS = (int) r; if (ss == 6) // Press the OK button {Foreach (String S in Directory.GetFiles) // Put the full path name { File.delete (s); // Delete this file}}}}}

(2). Compilation method:

After compiling after the following command line, a Windows execution file --RecyCled.exe is formed.

CSC / T: Winexe /R :system.dll /r:system.windows.forms.dll Recycled.cs

Doing this file will get the following execution interface:

Figure 01: Program Executive Interface

5. Summary:

This article is a systematic manner to specifically explain the powerful function of Visual C # through a software system, in fact, in fact, is only a small application in the file processing in Visual C #. Not only that, Visual C # also has a powerful function in other respects. With this powerful backing of .NET Framework SDK, Visual C # makes problems in the previous program have relatively simple, making the problem that is not possible to handle, this is why Visual C # becomes next generation Mainstream programming language.

转载请注明原文地址:https://www.9cbs.com/read-17007.html

New Post(0)