I have a C# code that basically uploads a file via FTP protocol (using FtpWebRequest
). I'd like, however, to first determine whether there is a working internet connection before trying to upload the file (since, if there isn't there is no point in trying, the software should just sleep for a time and check again).
Is there an easy way to do it or should I just try to upload the file and in case it failed just try again, assuming the network connection was down?
Can't you just use the Ping Class of the System.Net.NetworkInformation Namespace to ping the FTP server before trying to upload the file?