How to validate a file path ?

M

mscertified

I need the user to enter a location where a file will be saved, so I need to
check the file path exists. I don't need to check the file itself as if it
does not exist, I will create a new file. I don't want to display the Windows
File save Dialog, I just have a text box for entry of a file path.
 
M

MikeC

If Dir(strTargetFolder, vbDirectory) <> "" Then
FileCopy strSourceFolder & "\" & strFileName, strTargetFolder & "\" &
strFileName
End If
 
M

Marshall Barton

mscertified said:
I need the user to enter a location where a file will be saved, so I need to
check the file path exists. I don't need to check the file itself as if it
does not exist, I will create a new file. I don't want to display the Windows
File save Dialog, I just have a text box for entry of a file path.


You can uae the Dir function:

folderpath=Left(filepath,Len(filepath)-Len(Dir(filepath))-1)
If Dir(folderpath, vbdirectory) = "" Then
'directory does not exist
 

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