Delete folder of network hard disk designed by ASP. NET

Source: Internet
Author: User
Users who no longer need files/folders have the permission to delete them. This section describes how to implement this function.

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.

CodeImplementation

On the Design panel, double-click the delete button to add event processing to it.ProgramAs follows:

Private void btndelete_click (Object sender, system. eventargs E)
{
Deletethings (filelistselecteditem. Text );
}
Private void deletethings (string fullpath)
{
If (fullpath. indexof (".") & gt; 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.

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.