[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
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...
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.