Asp. NET Design Network HDD Delete Folder implementation Code _ practical skills

Source: Internet
Author: User
Interface layout

There is a "delete" button in the main interface design, which (ID) is btndelete. When the user selects the item to be deleted in the directory browsing, the delete work can be completed by clicking the button.

Code implementation

Double-click the Delete button in the design panel to add an event handler for it as follows:
Copy Code code 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 files
{
File.delete (FullPath);
Loaddir (Currentpath); Reload the current directory
}
else//Delete directory
{
Directory.delete (FullPath);
Loaddir (Currentpath); Reload the current directory
}
}

When you delete, you first determine whether the file or folder is selected. If it is a file, the File.delete () method is invoked, or the Directory.delete () method is invoked. After the deletion succeeds, the Loaddir () method is called to display the changed directory contents.

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.