我正试图从我的web服务下载一个文件(.txt)。我的web服务使用此代码
WebClient req = new WebClient();
HttpResponse Response = HttpContext.Current.Response;
Response.ContentType = "image/jpeg";
Response.AddHeader("Content-Disposition", "attachment;filename=" +
fileName);
Response.WriteFile("C:\Temp\Storage\" + (fileName));
Response.End();
我想从客户那里打电话。这是怎么做到的?
private void btnDownload_Click(object sender, EventArgs e)
{
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri("http://NikUser.com/myfile.txt"), @"c:myfile.txt");
}
试试看。。。。希望它能起作用。。。