Results 1 to 5 of 5

Thread: Files

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    55

    Files

    The code below is suppose to find any directories in App.Path & "Configuered\*.*" Delete all files in the directories it finds , then delete the directories. This code only works someone of the time and only if there are files in the directories it finds. Can anyone help me fix this?

    Code:
    FileLister = Dir$(App.Path & "\Configured\*.*", vbDirectory) 'Remove all directories and files in direcotries in App.Path & "\Configured\*.*"
    Do While Len(FileLister)
        If Mid$(FileLister, 1, 1) <> "." Then
            FileLister2 = Dir$(App.Path & FileLister & "\*.*")
                Do While Len(FileLister2)
                    Kill App.Path & "\Configured\" & FileLister & "\" & FileLister2
                    FileLister = Dir
                Loop
            RmDir App.Path & "\Configured\" & FileLister
        End If
        FileLister = Dir
    Loop
    -Sensimillia

  2. #2
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    Do you get an error when it does not work? And if you don't, are you using On Error Resume Next?

    Kill will generate an error on an open file.
    RmDir will generate an error if the directory is not empty.

    You should be trapping these errors and dealing with them.

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    55
    just cause i'm posting on the generals board does not mean i'm stupid. I am not tring to delete and open file. Also I do not need error trapping in my program since there are no error occuring.

    Thankz for tring to help though.

    I figured it out.

    wanna see?


    Code:
    FileLister = Dir$(App.Path & "\Configured\*.*", vbDirectory) 'Remove all directories and files in directories in App.Path & "\Configured\*.*"
    While Mid$(FileLister, 1, 1) = "."
        FileLister = Dir
    Wend
    Do While Len(FileLister)
            filelister2 = Dir$(App.Path & "\Configured\" & FileLister & "\*.*")
                Do While Len(filelister2)
                    Kill App.Path & "\Configured\" & FileLister & "\" & filelister2
                    filelister2 = Dir
                Loop
            RmDir App.Path & "\Configured\" & FileLister
        FileLister = Dir$(App.Path & "\Configured\*.*", vbDirectory)
        While Mid$(FileLister, 1, 1) = "."
            FileLister = Dir
        Wend
    Loop
    This code works flawlessley. :0)
    -Sensimillia

  4. #4
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    just cause i'm posting on the generals board does not mean i'm stupid. I am not tring to delete and open file.
    Yow! I never said you were stupid. You should have pointed out you were not receiving any errors. Everyone has overlooked the obvious before - stupid or not.

    Also I do not need error trapping in my program since there are no error occuring.
    Famos last worlds. Good luck with that one.

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    55
    True. My appoligies.
    -Sensimillia

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