|
-
Oct 28th, 2001, 11:57 AM
#1
Thread Starter
Member
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
-
Oct 28th, 2001, 12:43 PM
#2
Frenzied Member
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.
-
Oct 28th, 2001, 12:51 PM
#3
Thread Starter
Member
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)
-
Oct 28th, 2001, 12:55 PM
#4
Frenzied Member
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.
-
Oct 28th, 2001, 12:57 PM
#5
Thread Starter
Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|