Deleting a set of file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Deleting a set of file

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Location
    caracas
    Posts
    7

    Deleting a set of file

    Hi, I want to delete a set of files but in an efficient way.
    I have an array of string called filesToUse that contains the list of files names to keep in disk. Then, I search in my folder all files but I need check every files do not match with any element in my array. By example:
    Code:
    foreach(string sFile in System.IO.Directory.GetFiles("C:\\*.bmp"))
    {
        bool flag = false;
        foreach (string s in filesToUse)
            if (s.Equals(sFile))
              flag = true;
        if(flag) System.IO.File.Delete(sFile); //anyone of these are in filesToUse
    }
    I think that both foreach is unnecessary, any better solution without use 2 for's?
    Thanks in advance

    esmitt

  2. #2
    Join Date
    Oct 2008
    Posts
    142

    forfiles.exe

    hi there,

    this is not a dotnet solution, but deleting files is recommended with forfiles.exe utility.

    here is information about forfiles.exe --> http://www.google.com/#sclient=psy&h...50e40e87b009cf

    best regards,

    tonci korsano

Similar Threads

  1. Create XML file from a string in SQL server 2000
    By shan_2007 in forum Database
    Replies: 0
    Last Post: 12-11-2007, 07:34 AM
  2. Replies: 0
    Last Post: 09-22-2007, 07:54 AM
  3. Deleting a file using Windows Service
    By adjones1980 in forum .NET
    Replies: 2
    Last Post: 07-26-2007, 06:53 PM
  4. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 11:40 PM
  5. File uploading / objFile.Write problem
    By Tomer Cagan in forum ASP.NET
    Replies: 1
    Last Post: 07-24-2001, 10:01 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center