folderexists wildcard?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to find out if a folder exists on my network before I create a new one. My naming rules start each folder with a case number, but users can add friendly client names after the case number manually for their convience
Problem: I can't get my test to true when checking to see if a folder already exists if a user has appended onto the end of the file name
Example: "\04-0784" should not be created if "\04-0784*" exists
I think I'm getting my wildcard wrong in the folderexists method of the FileSystemObject

If fs.folderexists(path & "*") = True The
projectFolderExists = Tru
End I

I've tried using "?" and "%". Out of ideas... Can anyone give me a hand? Thanks!
 
If the folder exists, then

dir("C:\WinNT\",vbDirectory )

will return a "." Otherwise, it will be an empty string


Chris Nebinger

-----Original Message-----
I'm trying to find out if a folder exists on my network
before I create a new one. My naming rules start each
folder with a case number, but users can add friendly
client names after the case number manually for their
convience.
Problem: I can't get my test to true when checking to see
if a folder already exists if a user has appended onto the
end of the file name.
Example: "\04-0784" should not be created if "\04-0784*" exists.
I think I'm getting my wildcard wrong in the folderexists
method of the FileSystemObject.
 
Okay, you caught me. I didn't read your original post too
closely.

Dim strDirectory As String
strDirectory = Dir("C:\Win*.", vbDirectory)
Do Until strDirectory = ""
Debug.Print strDirectory
strDirectory = Dir
Loop


Results:
WINNT
WINNTMore


Note, it still returns winzip.zip or something to that
effect, so that is why the win*. is there. You can then
do a dir on the returned path and look for a "."

Also, can you trap an error about a path not existing?

Chris Nebinger

-----Original Message-----
Thanks for the reply.
But what if, using your example, all I know about the
folder name is "WinNT" - but it could be "WinNTAndMore" ?
 
Back
Top