我要求在C#中下载以下文件,并且对话框显示说文件已下载,所以当我去检查文件夹时,文件没有下载!
private void Button_Click_1(object sender, RoutedEventArgs e) {
string url = @"http://dc451.4shared.com/download/eWW2ICvX/Alexville.zip?tsid=20130402-163358-7222b14a";
// Create an instance of WebClient
System.Net.WebClient client = new System.Net.WebClient();
// Hookup DownloadFileCompleted Event
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
// Start the download and copy the file to c:\temp
client.DownloadFileAsync(new Uri(url), @"C:\Users\PC\Desktop\Medieval Silver Edition");
}
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) {
MessageBox.Show("File downloaded");
}
答案 0 :(得分:0)
你还没有给它一个文件名。
client.DownloadFileAsync(new Uri(url),
@"C:\Users\PC\Desktop\Medieval Silver Edition\Alexville.zip");