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.
 
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
 
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
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top