Copying a file timestamp to another file

Just starting out? Need help? Post your questions and find answers here.
wallgod
User
User
Posts: 48
Joined: Wed Oct 06, 2010 2:03 pm

Copying a file timestamp to another file

Post 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?
Procrastinators unite... tomorrow!
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: Copying a file timestamp to another file

Post 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
wallgod
User
User
Posts: 48
Joined: Wed Oct 06, 2010 2:03 pm

Re: Copying a file timestamp to another file

Post by wallgod »

Oh whoops! That did it. Thank you.
Procrastinators unite... tomorrow!
Post Reply