a special use of the File System Object's fso.folderExists() function

P

Paul

I'm using the File System Object to manage files and folders, and one common
operation is confirming that a file exists:

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.folderExists(strPath) Then
. . .
End If

Is there any way to use wildcard characters in the fso.folderExists()
function to do two things:

1. Test for the existence of a folder where the first six characters,
Left(strPath,6), are known, but the rest of the folder name is not known,
and
2. Return the full name of that folder.

To provide some context for this request, we've developed a very useful file
management system that organizes documents and folders by six digit project
numbers. It works great, in part because the primary key project numbers
are unambiguous. However, the numbers are meaningless to users when they're
looking at the folders in Windows Explorer. So the users have asked if
there's any way we can append meaningful strings to those six-digit
numbers - specifically street addresses. In order to do this, and still
manage the folders and their contents from our Access database, I need to be
able to do the two things I listed above.

Is there any way to do this?

Thanks in advance,

Paul
 
P

Paul

You're right, Bonnie, Dir() is what I need to use. I started experimenting
with it, and found that

Dir(strpath & "*", vbDirectory)

will give me the full name of a directory where I only know the first six
characters of the folder name. Thanks for your help, and thanks for the
link to the VB code for listing all files in a folder.

BTW, nice Web site you've got there at DataPlus - clear, simple, and it
still tells you everything you need to know.

Thanks much.

Paul



bhicks11 via AccessMonster.com said:
Maybe DIR would work better for you.

Myfile = Dir("C:\*.txt")
?myfile = ""

If false - you've got your file.

Bonnie

Found this:

http://www.freevbcode.com/ShowCode.Asp?ID=1487

Bonnie
http://www.dataplus-svc.com
I'm using the File System Object to manage files and folders, and one
common
operation is confirming that a file exists:
[quoted text clipped - 28 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top