check if file path is valid

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

Hello All -

Is there a way to check if a file path string is valid? I.e. is there
a function that takes some string, say 'c:\somedir\subdir' and returns
TRUE if it is valid or FALSE if no such path exists?

Thanks!
Brian
 
Hello All -

Is there a way to check if a file path string is valid? I.e. is there
a function that takes some string, say 'c:\somedir\subdir' and returns
TRUE if it is valid or FALSE if no such path exists?

Thanks!
Brian

Imports System.IO

....

If Directory.Exists("c:\my directory") Then
...
End If

If File.Exists("C:\my directory\myfile.txt") Then
....
End If
 
* (e-mail address removed) (dave) scripsit:
Is there a way to check if a file path string is valid? I.e. is there
a function that takes some string, say 'c:\somedir\subdir' and returns
TRUE if it is valid or FALSE if no such path exists?

'System.IO.Directory.Exists'.
 
Hello All -

Is there a way to check if a file path string is valid? I.e. is there
a function that takes some string, say 'c:\somedir\subdir' and returns
TRUE if it is valid or FALSE if no such path exists?

Thanks!
Brian

This used to work in VB6, I havn't tried it in .NET yet.....

if dir$("C:\Myfile.xxx")="" then 'the file does not exist

if it does exist, it returns the filename back to you.

Scott
 
* Scott Hather said:
This used to work in VB6, I havn't tried it in .NET yet.....

if dir$("C:\Myfile.xxx")="" then 'the file does not exist

if it does exist, it returns the filename back to you.

This code has some disadvantages in VB6, it should not be used to check
if a file exists.
 
Back
Top