Using FolderExist from Scripting.FileSystemObject (1 Viewer)

FuzMic

DataBase Tinker
Local time
Today, 18:06
Joined
Sep 13, 2006
Messages
719
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.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:06
Joined
Feb 28, 2001
Messages
27,140
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:06
Joined
Oct 29, 2018
Messages
21,454
I can't think of a better way either.
 

KitaYama

Well-known member
Local time
Today, 19:06
Joined
Jan 6, 2022
Messages
1,540
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:
 

FuzMic

DataBase Tinker
Local time
Today, 18:06
Joined
Sep 13, 2006
Messages
719
ok ok Thanks for sharing .. what i mean by better is whether it is high success rate to detect.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:06
Joined
Feb 28, 2001
Messages
27,140
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

Top Bottom