Asp.net C#ASPX从本地主机下载文件

Asp.net C#ASPX从本地主机下载文件,asp.net,Asp.net,我正在尝试从web服务下载文件(.txt)。我的web服务使用此代码 WebClient req = new WebClient(); HttpResponse Response = HttpContext.Current.Response; Response.ContentType = "image/jpeg"; Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); Response

我正在尝试从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");
}
试试看。。。。希望它能起作用……

您是否尝试过使用该方法,如果是,问题是什么?