0

我正在尝试从我的 Web 服务下载文件 (.txt)。我的网络服务使用此代码

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();

我想从客户那里打电话。这是怎么做的?

4

1 回答 1

0
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");
}

试试吧....希望它会工作...

于 2013-02-15T10:32:59.120 回答