How to check to see if a file exist.

D

Dave

How can i check to see if a link (file) exist while a web page is loading.
If the page doesn't exist - i want the hyperlink to go an error page telling
the user the link doesn't exist otherwise they will just go the link which
is a pdf file.

I'm using asp.net 2003.

thanks

Dave
 
S

Scott Allen

Hi Dave:

Is this a local file on the server? If so, you could use File.Exists
to check (from the System.IO namespace). Don't forget to use
Server.MapPath to get a physical path to the file.

HTH,
 

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

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top