Page 1 of 1

Copying a file timestamp to another file

Posted: Fri Oct 15, 2010 10:26 pm
by wallgod
How do I copy a file's timestamp (created, accessed, modified) from one file to another?
Here's what I tried, but it doesn't work:

Code: Select all

Procedure CopyFileStamp(file1.s, file2.s)
    Protected created=GetFileDate(file1, #PB_Date_Created)
    Protected accessed=GetFileDate(file1, #PB_Date_Accessed)
    Protected modified=GetFileDate(file1, #PB_Date_Modified)
    SetFileDate(file2,created,created)
    SetFileDate(file2,accessed,created)
    SetFileDate(file2,modified,created)
EndProcedure
What am I doing wrong?

Re: Copying a file timestamp to another file

Posted: Fri Oct 15, 2010 11:19 pm
by Vera
Hello,

well I didn't build a running example with your snippet, but it looks as if you just missed the DateType:

Code: Select all

SetFileDate(file2, #PB_Date_Created, created)
SetFileDate(file2, #PB_Date_Accessed, accessed)
SetFileDate(file2, #PB_Date_Modified, modified)
greetings ~ Vera

Re: Copying a file timestamp to another file

Posted: Sat Oct 16, 2010 2:32 am
by wallgod
Oh whoops! That did it. Thank you.