Results 1 to 3 of 3

Thread: [RESOLVED] [VS2008] Read contents of text file from a web site - IF connection and file exists

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Posts
    159

    Resolved [RESOLVED] [VS2008] Read contents of text file from a web site - IF connection and file exists

    I want to be able to check to make sure that the most current version of my application is being used, so I have a text file on my website which contains the full build number in the standard format w.x.y.z

    I can already download the contents of the file into a text buffer, but I want some extra "safeguards" to stop my code from crashing.

    1) I want to check first to make sure that there is an active connection to the internet, and...

    2) ...if there is, I want to make sure that the file exists before trying to read the contents of the file.

    How can this be done?

    Thanks

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Posts
    159

    Re: [VS2008] Read contents of text file from a web site - IF connection and file exists

    Never mind... Am using a Try / Catch to attempt to open the remote file...

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] [VS2008] Read contents of text file from a web site - IF connection and file exists

    Use a "using" for the HttpWebRequest and check the StatusCode property to see if it's a 200 or a 404 or 500 being returned.

Posting Permissions

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



Click Here to Expand Forum to Full Width