[RESOLVED] [2008] Detect if a path is in a valid format
Sorry if this is a simple question, but here it goes. I have a program that allows a user to either select a output filename or manually type the output filename. Is there any way to check if the path\filename are in the proper format? Since it may not exist yet, I am trying to check if it is a valid format (ie C:\Whatever\Whatever.abc) before I create the new file.
Would I have to check each piece for existance? The drive letter (C:\), the folder (C:\Whatever) and that the filename has an extension, even if not valid.
I was just wondering if there is anything easier.
Thanks for any input.
Re: [2008] Detect if a path is in a valid format
You could do it by checking if the directory exists (something like If System.Directory.Exists("C:\Whatever\") = True Then everything's alright)
But couldn't you just use a simple Try / Catch there?
Code:
Private Sub SaveFile()
Try
Dim ObjWriter As New System.IO.StreamWriter("C:\Whatever\abc.text")
Catch ex As Exception
MsgBox("Invalid path")
End Try
End Sub
Re: [2008] Detect if a path is in a valid format
I will give that a shot. Thank you for your response.