J
James Write
Hi,
I am using the webclient.downloadfile() method to download a file from
a remote web server to the local harddrive.
public CopyFile(string sSrcPath, string sDestPath)
{
WebClient oClient = new WebClient();
oClient.DownloadFile(sSrcPath,sDestPath);
}
Is there anyway i can determine that if the local file exists already
and the file from the web server is newer download it, otherwise
leave it? (Conditional Get) tried accessing the Headers property and
setting the "if-modified-since" to that of the localfiles last write
time, but i get an exception that i can't modify that header property.
try
{
FileInfo oFileInfo = new FileInfo(sDestPath);
if(oFileInfo.Exists)
{
DateTime t = oFileInfo.LastWriteTime.ToUniversalTime();
oClient.Headers["if-modified-since"] = t.ToString("r");
}
oClient.DownloadFile(sSrcPath,sDestPath);
}
Any ideas greatly appreciated.
Cheers.
I am using the webclient.downloadfile() method to download a file from
a remote web server to the local harddrive.
public CopyFile(string sSrcPath, string sDestPath)
{
WebClient oClient = new WebClient();
oClient.DownloadFile(sSrcPath,sDestPath);
}
Is there anyway i can determine that if the local file exists already
and the file from the web server is newer download it, otherwise
leave it? (Conditional Get) tried accessing the Headers property and
setting the "if-modified-since" to that of the localfiles last write
time, but i get an exception that i can't modify that header property.
try
{
FileInfo oFileInfo = new FileInfo(sDestPath);
if(oFileInfo.Exists)
{
DateTime t = oFileInfo.LastWriteTime.ToUniversalTime();
oClient.Headers["if-modified-since"] = t.ToString("r");
}
oClient.DownloadFile(sSrcPath,sDestPath);
}
Any ideas greatly appreciated.
Cheers.