Verify File Exists


G

Guest

This is a tough one, but here goes.

I have a webform textbox where users input a filepath. For example:
\\servername\sharename\file.xls. Is there anyway that I could use VB code to
verify that the filepath and filename are valid after the user has input
them? Basically this would serve to quality check whether or not the user
has input the correct file path.

Thanks.
 
Ad

Advertisements

W

William F. Robertson, Jr.

bool System.IO.File.Exists( string file )

returns true or false if the file exists. The file parameter can be a UNC
path, but you have to ensure you have read permissions to the directory.

if System.IO.File.Exists( txtInput.Text ) = true Then
'the file exists
else
'the file does not exist
end if

bill
 
Ad

Advertisements

G

Guest

Perfect! Thank you William!!!

William F. Robertson said:
bool System.IO.File.Exists( string file )

returns true or false if the file exists. The file parameter can be a UNC
path, but you have to ensure you have read permissions to the directory.

if System.IO.File.Exists( txtInput.Text ) = true Then
'the file exists
else
'the file does not exist
end if

bill
 

Top