Results 1 to 5 of 5

Thread: How to Find *. Files and Delete them in any Folder?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    How to Find *. Files and Delete them in any Folder?

    Hi everybody!


    Ok, it seems to be a hard one .....

    I read 1561 threads before i posted this here.


    Unfortunatly it seems that everybody knows always the path in which the files are located. I don't know it, because the users have different folders for themself.

    I need to delete *.TMP Files and *.FIZ in any SubDirectory.

    I don't know in which SubDir are these Files. I need to make it fast and that it doesn't go to the Recycle Bin.

    I don't want that the user know that I delete the files and that he don't get disturbed with it while filling a form etc.
    The Files should be deleted as fast as possible.
    The PCs have usually not to many files on it, maybe 10.000 from this are maybe 200 that should be deleted.
    Is there a way to exclude SubDirectories to be searched to make it faster?

    I want that the program is as small as possible, that it doesn't need any extra file, only the exe-file itself. No MDAC or whatever.

    When I played a little around I got the problem that whenever I started this operations that the Form didn't finish to show completly on the monitor. After the operations finished it showed it.

    (If possible please show me an example code, hehe)

    nice greetings
    Franky

  2. #2
    Addicted Member nota141's Avatar
    Join Date
    Feb 2000
    Location
    The place down there under everyone else.
    Posts
    224
    i may somthing that may help i use it to find *.lck and *.net files from x drive and delete them. i will post it as soon as i get to my home comp.
    On Error wake up and try again ;-)
    ___________________________
    ICQ # 65392645
    email - [email protected]

    Visual Studio 6 ent with SP5 Running on XP with an AMD 1.2 ThunderBird with 512 MB RAM And a 120GB primary HDD (very sweet)

  3. #3
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    I dont have VB here hence just the bits
    Add a reference for the scritping object
    What I am pasting below is part of the code I wrote for a search program
    Code:
    'get the drives on the system and place them in an array
    'starting with the first drive 
    dim  objConn as New Scripting.filesystemObject
    'Start a for loop for each drivearray eleemt
        Set objDir = objConn.GetFolder(mstr)
       DeLeteFiles (objDir.Path)
    next
    
    
    Sub DeLeteFiles(ByVal strFolderName As String)
        Dim objChildFolder As Scripting.Folder
        Dim strActualFileName As String
        Set objChildFolder = objConn.GetFolder(strFolderName)
        strFileName = Trim(txtFileName.Text)
        strExtension = txtExtension.Text
        Dim mFold
        
        For Each mFile In objChildFolder.Files
               strActualFileName = mFile.Name
                if instr(1,strActualFileName,".tmp",1) > 0 or instr(1,strActualFileName,".fxz",1) > 0 then
       'delete file
        set a =  objconn.getfile(mfile)
        a.delete
        set a = nothing
        Next
       For Each mchildfolders In objChildFolder.SubFolders
            DeLeteFiles (mchildfolders.Path)
        Next
    End Sub
    I know isnt upto the mark, but hopes gives u a start.

  4. #4
    Addicted Member nota141's Avatar
    Join Date
    Feb 2000
    Location
    The place down there under everyone else.
    Posts
    224
    here is my del files prog
    Attached Files Attached Files
    On Error wake up and try again ;-)
    ___________________________
    ICQ # 65392645
    email - [email protected]

    Visual Studio 6 ent with SP5 Running on XP with an AMD 1.2 ThunderBird with 512 MB RAM And a 120GB primary HDD (very sweet)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    Thanks to both of you

    I checked the delFiles and it is fast enough. It doesn't block the Form so it is perfect. I will check anyway veryjohnnys too.

    Thanks again

    Franky

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width