【发布时间】:2014-06-19 16:39:10
【问题描述】:
我正在使用WebClient.DownloadFileAsync 方法从远程服务器通过 Windows 应用程序连接到我的本地计算机。我可以使用上述方法下载文件,但问题是文件在服务器上的“上次修改日期”在下载到我的机器时被修改为当前日期和时间。通过 Fiddler 下载文件时,我可以在文件的响应标头中看到上次修改日期。您能帮我保留文件的最后修改日期吗:我正在使用以下代码:
// Create a web client
using (var client = new IfModifiedSinceWebClient())
{
client.IfModifiedSince = File.GetLastWriteTimeUtc(path);
// Initiate an asynchronous download to a temporary file
var downloadPath = Path.GetTempFileName();
client.DownloadFileCompleted += new AsyncCompletedEventHandler(UpdateFileIfNewerDownloadFileCompleted);
client.DownloadFileAsync(uri, downloadPath, new UpdateFileIfNewerState(path, downloadPath, onComplete));
}
【问题讨论】:
标签: c# asynchronous download