How to check to see if a file exist.

Discussion in 'ASP .Net' started by Dave, May 18, 2004.

  1. Dave

    Dave Guest

    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
    Dave, May 18, 2004
    #1
    1. Advertising

  2. have a look at the customerror attributes in the webconfig file

    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    Got tidbits? Get it here... http://tinyurl.com/27cok
    "Dave" <> wrote in message
    news:...
    > 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
    >
    >
    Alvin Bruney [MVP], May 18, 2004
    #2
    1. Advertising

  3. Dave

    Scott Allen Guest

    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,

    --
    Scott
    http://www.OdeToCode.com

    On Tue, 18 May 2004 08:28:26 -0700, "Dave" <>
    wrote:

    >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
    >
    Scott Allen, May 18, 2004
    #3
  4. Dave

    Dave Guest

    Got it and it works

    thanks for help


    "Dave" <> wrote in message
    news:...
    > 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
    >
    >
    Dave, May 18, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Y.S.
    Replies:
    3
    Views:
    1,009
    strajan
    Sep 17, 2003
  2. LT
    Replies:
    7
    Views:
    2,092
    Phlip
    Jul 25, 2004
  3. pvong
    Replies:
    2
    Views:
    359
    Gregory A. Beamer
    Oct 1, 2009
  4. Markus Mohr
    Replies:
    7
    Views:
    246
    Thomas 'PointedEars' Lahn
    Nov 28, 2003
  5. Mel
    Replies:
    0
    Views:
    86
Loading...

Share This Page