2006. október 13., péntek

How to set the date stamp of a file equal to the date stamp of another


Problem/Question/Abstract:

How to set the date stamp of a file equal to the date stamp of another

Answer:

Just use the following function, which takes two strings representing full DOS path/ file names. The file who's date you wish to set is the second parameter, and the date you wish to set it to is given by the file in the first parameter.

procedure CopyFileDate(const Source, Dest: string);
var
  SourceHand, DestHand: word;
begin
  SourceHand := FileOpen(Source, fmOutput); { open source file }
  DestHand := FileOpen(Dest, fmInput); { open dest file }
  FileSetDate(DestHand, FileGetDate(SourceHand)); { get / set date }
  FileClose(SourceHand); { close source file }
  FileClose(DestHand); { close dest file }
end;

Nincsenek megjegyzések:

Megjegyzés küldése