ASP. NET design network hard disk deletion folder implementation code

Source: Internet
Author: User

Interface Layout

There is a "delete" button in the main interface design, and its (ID) is btnDelete. You can click this button to delete an item in directory browsing.

Code Implementation

On the Design panel, double-click the delete button to add an event handler for it as follows:
Copy codeThe Code is as follows:
Private void BtnDelete_Click (object sender, System. EventArgs e)
DeleteThings (FileList. SelectedItem. Text );

Private void DeleteThings (string FullPath)
If (FullPath. IndexOf (".")> 0) // delete an object
File. Delete (FullPath );
LoadDir (CurrentPath); // reload the current directory
Else // delete a directory
Directory. Delete (FullPath );
LoadDir (CurrentPath); // reload the current directory

When deleting a file, first determine whether the selected file is a folder or not. If it is a File, the File. Delete () method is called; otherwise, the Directory. Delete () method is called. After the deletion is successful, call the LoadDir () method to display the changed directory content.

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: 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.