我想抛出,如果在我的方法调用失败的异常,我的代码是迄今为止如下:C# - 抛出一个异常,如果无法连接到删除服务器
if (sourceFile.Exists)
// Would be nice to add ticker/spinner, while the file header on the remote server is being read!!
{
var request = (HttpWebRequest)WebRequest.Create(@"http://google.com/test.zip");
request.Method = "HEAD";
var response = (HttpWebResponse)request.GetResponse();
if (response.LastModified > sourceFile.LastWriteTime)
{
Download_Click(sender, e);
// use response.GetStream() to download the file.
}
你有什么问题吗? –
@ba__friend如果没有网络连接可用,我如何捕获异常 –
不要帮助,它已经发生。 –