Click here to Skip to main content
15,913,055 members
Home / Discussions / C#
   

C#

 
Questionhow to download file not to change timestamp using HTTP Pin
yu-yu26-Jan-04 17:26
yu-yu26-Jan-04 17:26 
AnswerRe: how to download file not to change timestamp using HTTP Pin
Heath Stewart27-Jan-04 3:02
protectorHeath Stewart27-Jan-04 3:02 
Do you mean the timestamp of the original file on your filesystem, or do you want to use the timestamp of the file that was on the server?

In the former case, if the file exists (see File.Exists) get the last modification date by using a FileInfo that points to it and store the FileInfo.LastWriteTime. After you finish writing the file, set the FileInfo.LastWriteTime to the DateTime you stored previously.

In the latter case, don't use the WebClient; use the HttpWebRequest and HttpWebResponse which are very easy to use and very robust. They are built on the asynchronous pluggable protocol system of .NET and if you look at the documentation for either of those you will find many useful examples.

So, after you make your request and call HttpWebRequest.GetResponse (and cast it to a HttpWebResponse), you can get the HttpWebResponse.LastModified date. AFter you write the file using a buffer, again create a FileInfo instance pointing to that download file and set the FileInfo.LastModified date.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: how to download file not to change timestamp using HTTP Pin
yu-yu27-Jan-04 15:31
yu-yu27-Jan-04 15:31 
GeneralSystem.XML.XMLDocument Pin
Anonymous26-Jan-04 16:04
Anonymous26-Jan-04 16:04 
GeneralRe: System.XML.XMLDocument Pin
Heath Stewart27-Jan-04 2:54
protectorHeath Stewart27-Jan-04 2:54 
QuestionThis cool thing!!...howz it done? Pin
srt726-Jan-04 13:27
srt726-Jan-04 13:27 
AnswerRe: This cool thing!!...howz it done? Pin
Colin Angus Mackay26-Jan-04 14:00
Colin Angus Mackay26-Jan-04 14:00 
GeneralRe: This cool thing!!...howz it done? Pin
srt726-Jan-04 14:55
srt726-Jan-04 14:55 
GeneralRe: This cool thing!!...howz it done? Pin
Colin Angus Mackay26-Jan-04 22:12
Colin Angus Mackay26-Jan-04 22:12 
GeneralRe: This cool thing!!...howz it done? Pin
srt726-Jan-04 17:04
srt726-Jan-04 17:04 
AnswerRe: This cool thing!!...howz it done? Pin
Mazdak26-Jan-04 19:34
Mazdak26-Jan-04 19:34 
GeneralRe: This cool thing!!...howz it done? Pin
srt727-Jan-04 3:45
srt727-Jan-04 3:45 
GeneralRe: This cool thing!!...howz it done? Pin
srt727-Jan-04 4:20
srt727-Jan-04 4:20 
GeneralClass library (COM) to read app.config Pin
stateyama26-Jan-04 11:27
stateyama26-Jan-04 11:27 
GeneralRe: Class library (COM) to read app.config Pin
Heath Stewart26-Jan-04 11:37
protectorHeath Stewart26-Jan-04 11:37 
GeneralRe: Class library (COM) to read app.config Pin
stateyama26-Jan-04 11:58
stateyama26-Jan-04 11:58 
GeneralRe: Class library (COM) to read app.config Pin
Heath Stewart26-Jan-04 12:02
protectorHeath Stewart26-Jan-04 12:02 
GeneralRe: Class library (COM) to read app.config Pin
stateyama26-Jan-04 12:19
stateyama26-Jan-04 12:19 
General.NET Remoting Question Pin
Brian Rogan26-Jan-04 11:00
Brian Rogan26-Jan-04 11:00 
GeneralRe: .NET Remoting Question Pin
Guillermo Rivero26-Jan-04 11:15
Guillermo Rivero26-Jan-04 11:15 
GeneralMouse click on the frame of a form Pin
Anonymous26-Jan-04 9:41
Anonymous26-Jan-04 9:41 
GeneralRe: Mouse click on the frame of a form Pin
Heath Stewart26-Jan-04 11:03
protectorHeath Stewart26-Jan-04 11:03 
GeneralC# Market Penetration for Freeware/Shareware Pin
telstar26-Jan-04 9:38
telstar26-Jan-04 9:38 
GeneralRe: C# Market Penetration for Freeware/Shareware Pin
Heath Stewart26-Jan-04 10:24
protectorHeath Stewart26-Jan-04 10:24 
GeneralRe: C# Market Penetration for Freeware/Shareware Pin
je_gonzalez26-Jan-04 11:29
je_gonzalez26-Jan-04 11:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.