How to check to see if a file exist.

  • Thread starter Thread starter Dave
  • Start date Start date
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
 
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,
 
Back
Top