dcsimg
Results 1 to 3 of 3

Thread: How to code to detect the file existing in http format?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    472

    How to code to detect the file existing in http format?

    I can code below to open the file

    dim filepath as string = "http://order/venommain.asp?f=N&username=0E3706&password=0E12Y6&docs=-1&folders=-1&sv=&e=-1&nw=&q1=TITLE+CONTAINS+PDFFILENAME"

    response.redirect(filepath) // it works and open PDFFILENAME

    But,

    System.IO.File.Exists(filepath) alway return false (it should return true)

    How to code to detect the file existing in http format?

  2. #2
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: How to code to detect the file existing in http format?

    Your file is actually a URL, so you want to use the HTTP methods to detect them.

    Code:
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://order/........");
    HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
    if (resp.StatusCode == HttpStatusCode.OK)
    {
    //Then it exists
    }

  3. #3
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: How to code to detect the file existing in http format?

    aspfun,

    Did the above answer your question?

    If so, can you remember to mark your thread resolved?

    Thanks

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width