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

Source: Internet
Author: User

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.

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.