How to validate a file path ?

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

Guest

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.
 
If Dir(strTargetFolder, vbDirectory) <> "" Then
FileCopy strSourceFolder & "\" & strFileName, strTargetFolder & "\" &
strFileName
End If
 
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
 
Back
Top