【发布时间】:2010-10-25 08:08:09
【问题描述】:
我正在将文件从远程位置下载到本地计算机。我使用的路径保存在 web.config 中,格式如下:
<add key="FileFolder" value="Files/"/>
<add key="LocalFileFolder" value="D:\REAL\" />
我用来下载的代码是:
CreateDirectoryIfDoesNotExist();
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
webClient.DownloadFileAsync(new Uri(context.Server.MapPath(ConfigurationManager.AppSettings["FileFolder"].ToString() + myfilename)), ConfigurationManager.AppSettings["LocalFileFolder"].ToString() + myfilename);
当我在服务器上部署它时;并运行我的程序,我收到一条消息说下载已成功完成。但问题是文件被下载到服务器机器上的文件夹(LocalFileFolder)中。我希望将其下载到本地计算机上。我到底做错了什么?
【问题讨论】:
标签: asp.net asynchronous webclient