|
-
Oct 2nd, 2007, 06:57 PM
#1
Thread Starter
Member
Can't delete folder
Hi Folks,
I am attempting to delete a temp folder after using it to upload files to my server via a form. I get the following:
Microsoft VBScript runtime error '800a004c'
Path not found
on this line:
fso.DeleteFolder("C:\path\to\my\folder\")
The same code works perfectly on another server, and the folder definitely exists (and I'm spelling it correctly), so I'm thinking it might be a permissions issue. I tried giving the IUSR full access, but that didn't work. I've also tried the "True" argument with no luck.
Any ideas would be appreciated.
Thanks
-
Oct 3rd, 2007, 04:48 AM
#2
Re: Can't delete folder
Check before deleting that folder.Like
Code:
If fso.FolderExist("C:\path\to\my\folder\")=true then
fso.DeleteFolder(""C:\path\to\my\folder\")
End if
Please mark you thread resolved using the Thread Tools as shown
-
Oct 4th, 2007, 08:06 AM
#3
Junior Member
Re: Can't delete folder
 Originally Posted by danasegarane
Check before deleting that folder.Like
Code:
If fso.FolderExist("C:\path\to\my\folder\")=true then
fso.DeleteFolder(""C:\path\to\my\folder\")
End if
Just a small thing. First, FolderExists, not FolderExist 
Also, the statement following an IF must evaluate to either TRUE or FALSE. So, saying "If (some expression that evaluates to true) = (true)" is the same as saying "if (some expression that evaluates to true)".
So, the above is completely valid as:
Code:
If fso.FolderExists("C:\path\to\my\folder\") then
and if you want to run the code if it doesn't exist
Code:
If Not fso.FolderExists("C:\path\to\my\folder\") then
Makes a bit more sense, IMHO
-
Oct 5th, 2007, 10:56 PM
#4
PowerPoster
Re: Can't delete folder
 Originally Posted by lansalot
Also, the statement following an IF must evaluate to either TRUE or FALSE.
Only in this case, and some others, but it could also be any kind of variable type, such as a String. He had it the right way though (except the FolderExist part), but I also cut out the = True myself most times.
Question to the OP, is this XP or Vista?
-
Oct 19th, 2007, 07:10 AM
#5
Junior Member
Re: Can't delete folder
 Originally Posted by rory
Only in this case, and some others
An IF must ALWAYS evaluate to true or false, there are no "other cases" I'm afraid...
The hint about dropping "=true" is just that - a hint. It makes for cleaner code and it may make a shorter execution path when compiled as well. Perhaps there's a minute speed gain to be had if testing something in a very tight loop repeatedly for example.
Just trying to be helpful
-
Oct 19th, 2007, 04:18 PM
#6
PowerPoster
Re: Can't delete folder
 Originally Posted by lansalot
An IF must ALWAYS evaluate to true or false, there are no "other cases" I'm afraid...
Dim A, B
A = "This"
B = "That"
If A = B Then ....
...
If A Then ... <-- Error
-
Oct 20th, 2007, 07:09 AM
#7
PowerPoster
Re: Can't delete folder
 Originally Posted by lansalot
The hint about dropping "=true" is just that - a hint. It makes for cleaner code and it may make a shorter execution path when compiled as well. Perhaps there's a minute speed gain to be had if testing something in a very tight loop repeatedly for example.
Just trying to be helpful 
I know you are trying to be helpful. Just saying. It might make for a less code, but could be harder to identify code later down the road; I actually find it easier to read with the type of returns. And also when you need to replace variables using = makes life easier. I use it in in my code also, depends on what im doing, though a huge project I am working on currently, I am putting what I can back to = true or false, and using Call for all functions and subs. The only time I wont use it is when i have 2 of the same thing, like if Len(a) and Len(b) > 0 Then.
As to speed, I just ran a test using for next loops and arrays. Im more surprised at how fast my 6 year old 2.0Ghz 512MB RAM PC is than anything but the results were varying, this is also with closing the project out and reopening before each test of each method:
Using Booleans (if a = true then, if a then), array and loop set to 99 million
With= 12.46875, 12.4375, 11.85938, 12.96875
Without 11.75, 12.28125, 11.73438, 11.6875
Looks like not using it gains a tiny bit of speed, very minimal however, and as you can see it varies alot. Course this was with 99 million arrays in a loop doing not a whole lot though. Maybe I should at least leave my booleans the way it is, without. 
Using Strings (if Len(a) > 0 then, if Len(a) then),
used 90,000 this time, strings are alot bigger memory.
With > 11.89063, 13.34375, 12.01563, 11.8125
Without 12.95313, 11.98438, 12.1875, 12.32813
Slight difference with strings, looks like using > 0 is faster most times.
Still, for demonstration purposes I think they should use =, >, etc. as it could be a beginner who doesnt know what that should return, a Boolean or a String for example, could be any VBA or VBScript function.
Hope that helps. :-)
If you want the code its in a VB6 project.
Rory
-
Oct 22nd, 2007, 08:41 AM
#8
Junior Member
Re: Can't delete folder
 Originally Posted by rory
Dim A, B
A = "This"
B = "That"
If A = B Then ....
...
If A Then ... <-- Error 

Of course it's an error - you aren't making a statement that can possibly evaluate in terms of True or False. Hence my saying that an IF statement must ALWAYS evaluate to either true or false. Saying that it doesn't always have to by showing that it throws an error if you don't, well, umm.. kind of proves my point, no ?
In the above, the longhand of "If A=B" is actually "If (A=B)=true" when you add the =true construct...
Nice work on the testing however, I wouldn't have bothered my azz... 
All up to the individual and their coding style I guess.
-
Oct 22nd, 2007, 02:11 PM
#9
PowerPoster
Re: Can't delete folder
 Originally Posted by lansalot
Of course it's an error - you aren't making a statement that can possibly evaluate in terms of True or False. Hence my saying that an IF statement must ALWAYS evaluate to either true or false. Saying that it doesn't always have to by showing that it throws an error if you don't, well, umm.. kind of proves my point, no ?
In the above, the longhand of "If A=B" is actually "If (A=B)=true" when you add the =true construct...
Nice work on the testing however, I wouldn't have bothered my azz...
All up to the individual and their coding style I guess.
LOL .. okay I see what you mean now .. I was talking about what the function or query returns though; string, boolean, long, etc. Thats why yah lost me there for a minute.
After the testing, I went back to my current project and for all the functions that return booleans, took out all the ='s
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
|