|
-
Nov 5th, 2011, 10:49 AM
#1
Thread Starter
Addicted Member
Don't mess with fso (?)
Hi,
I have a userform that creates scenarios. In order to save them there are two options:
Set fso = CreateObject("Scripting.FileSystemObject")
- If the folder named [scenario] doesn't exist, create it with fso.createfolder("path")
- If the folder named [scenario] exists, delete
it with fso.deletefolder("path") create it with fso.createfolder("path")
Pretty simple.
The tricky part is that at some point it started popping an error message for option 2 saying it coulnd't create the folder because it already existed, but there wasn't any folder. Moreover, once I tried to delete the main folder where I as saving these folders it turned out I can't and Windows pops the following error message:
An unexpected error is keeping you from deleting the folder. if you continue to receive this eror, you can use the code to search for help with this problem.
Error 0x80070091: The directory is not empty
But it's empty! It seems the one way to delete this folder is to do it in safe mode. Was this caused by the createfolder method? Thank you in advance.
Regards,
Samuel
-
Nov 5th, 2011, 07:27 PM
#2
Re: Don't mess with fso (?)
once I tried to delete the main folder where I as saving these folders
does it have subfolders?
did you check in your code if the folder is empty, even for hidden files, created by windows?
why use fso to do this anway? though i doubt if the problem is caused by fso, there are alternative methods
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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
|