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