Using FolderExist from Scripting.FileSystemObject

FuzMic

DataBase Tinker
Local time
, 07:59
Joined
Sep 13, 2006
Messages
739
Hi Gurus

I use Scripting.FileSytemObject (FS) to check if a shared folder "Data" in a "MainPC" in a LAN Workgroup exist .. as in ...

FS.FolderExists("\\MainPC\Data\")

Is this a good way or is there another better way to do it.
 
It should work just fine. There are SOME reports that having a space embedded in some member of the path string can sometimes cause problems, but if you assure that the whole string is passed with properly surrounding quotes then you should be OK. That is, the worst problem I've seen reported was syntax of the call, not whether the function would fail to find an extant folder.
 
I can't think of a better way either.
 
Not that it's a better method, but I read somewhere Dir can be preferable in some cases. Because it's native to VBA.
It can also accept wildcards (* ?) and can check file or folder attributes.
I can't find the page at the moment. I may be wrong though.

Edit: I couldn't find the page. But I found this one:
 
ok ok Thanks for sharing .. what i mean by better is whether it is high success rate to detect.
 
To my understanding, the only problem will be whether the syntax of the call accurately specifies what you are trying to find PLUS the consideration that if you tried to find an arbitrary sub-directory but didn't have READ rights to a higher level directory in the same path, you might fail. Neither of those are problems with bad code in the function but rather, bad input or bad circumstances.
 

Users who are viewing this thread

Back
Top Bottom