Use Visual C # To clear the recycle bin (2)

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.