SoFunction
Updated on 2025-04-11

Programming method to delete folders and files under folders

Programming method to delete folders and files under folders

Updated: November 25, 2015 10:14:15 Author: happy664618843
This article mainly introduces the method of programming to delete folders and files under folders, involving traversal and deletion operations for files and directories. It has certain reference value. Friends who need it can refer to it.

This article describes the method of deleting folders and files under folders. Share it for your reference, as follows:

//Get folderstring path = ("Image");
//Get all pictures in the folderif ((path).Length > 0) 
{
  //Transfer all files in the folder  foreach (string file in (path))
  {
   //The file exists   if ((file)) 
   {
    FileInfo fi = new FileInfo(file);
    //Judge whether the current file attribute is read-only    if (().IndexOf("ReadyOnly") >= 0) 
    {
      = ;
    }
    //Delete the file    (file);
   }
  }
  //Delete the folder  (path);
}

I hope this article will be helpful to everyone's programming.

  • delete
  • document

Related Articles

  • Repeater interlaced color change and the mouse stays on top to achieve color change effect

    The mouse stays on it and turns into other colors. Many novices want to achieve this effect, but they have no idea how to start. This article has compiled some solutions. Interested friends can refer to it.
    2013-01-01
  • Code to implement hierarchical display using GridView

    In actual project development, it is often necessary to implement hierarchical display of the items on the page, and there are no ready-made controls in it.
    2010-06-06
  • Solutions to prevent malicious refresh of websites and sessions

    This article mainly introduces the cookies and session solutions for websites to prevent malicious refresh, and explains the skills of using cookies and session methods to prevent malicious refresh of WEB pages in the form of examples. Friends who need it can refer to it
    2014-09-09
  • MVC4 uses MongoDB to create photo album management

    This article mainly introduces the relevant information about MVC4 using MongoDB to create photo album management. Interested friends can refer to it.
    2016-07-07
  • How to configure database connections

    A file is an XML text file that stores configuration information for a web application (such as the most commonly used way to set up authentication for web applications), and it can appear in every directory of the application. This article mainly introduces two ways to configure database connections, let’s take a look together.
    2015-10-10
  • VS2012 implements a simple login interface

    This article mainly introduces the simple login interface of VS2012, which has certain reference value. Interested friends can refer to it.
    2018-06-06
  • Example of multi-condition search using three layers

    The three layers divide the project into an interface layer, a business logic layer and a data access layer. The following is a description of how to use the three layers to realize multi-condition retrieval. Interested friends can refer to it.
    2014-07-07
  • Alibaba Big Fish SMS Simple Send Function.net core version

    This article mainly introduces the .net core version and .net core version of Alibaba Dayu Send SMS function. It is just a simple SMS function for your reference. Interested friends can refer to it.
    2016-07-07
  • Use methods of sending information and transferring files

    This article mainly introduces the methods of sending information and transferring files. It analyzes the relevant techniques for implementing information and file transfer based on socket based on examples. Friends who need it can refer to it.
    2016-06-06
  • Prevent SQL injection attacks

    The usual way to prevent SQL injection attacks on the website is to modify and add filter code to each file, which is very troublesome. Here is a way to prevent injection from the entire website.
    2009-06-06

Latest Comments