Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to search to see if a folder exists 2

Status
Not open for further replies.

sm2605

Programmer
Nov 19, 2003
44
0
0
US
Hi, i would like to find out how to search a particular directory to see if a particular folder exists. Here is what i have so far:

dataDirectory = getKey("software\financial\Paths\User Path")

'check to see if datadirectory\Temp Folder exists

 
dim fso as FileSystemObject

Set fso = New FileSystemObject
If Not fso.FolderExists(vntPath) Then
'some action taken
End If

you'll have to add a reference to the Microsoft Scripting Runtime
 
Tons of threads on this here's a good one to see if file exist, it just needs modification.
thread222-358873
 
You dont need to reference F.S.O., try this instead...

Private Sub Command1_Click()
MsgBox DirExists ("C:\windows")
End Sub

Public Function DirExists(ByVal Directory As String) As Boolean
If Dir(strPath, vbDirectory) <> &quot;&quot; Then DirExists = True dir exists
End Function
 
In referance to LPlates post of code:


Public Function DirExists(ByVal Directory As String) As Boolean
If Dir(strPath, vbDirectory) <> "" Then DirExists = True dir exists
End Function

CHANGES in BOLD TO MAKE IT WORK BELOW:

Public Function DirExists(ByVal strPath As String) As Boolean
If Dir(strPath, vbDirectory) <> "" Then DirExists = True 'dir exists
End Function

Sorry, just wanted to help and put my two cents worth..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top