On AppleScript, heres what I got for CreationDate and Modification date:
[b]creation date[/b] (date, r/o) : the date on which the item was created
[b]modification date[/b] (date) : the date on which the item was last modified
I am not saying that it is not possible to change the creation date, but you have to make a quest on Apple Developer web about it to make sure (IMHO).
The code above works fine on El Capitan (in a button):
I added to a Project a PushButton,
I pasted Sasha code (read below) to its Action Event,
I created a folder beside the project and I called it FolderName,
Then run the project and clicked in the PushButton.
The create date is now 1999-09-09 as asked.
[code]Sub Action()
Dim f as FolderItem
f = GetFolderItem(“FolderName”)
If f = Nil Then
MsgBox Str(f.LastErrorCode)
Return
End If
Dim newDate As New Date
newDate.Year = 1999
newDate.Month = 9
newDate.Day = 9
f.CreationDate = newDate
If f .LastErrorCode <> 0 Then
MsgBox Str(f.LastErrorCode)
End If
End Sub[/code]
Move the file to the temp folder, open in binarystream with read mode, open another binarystream in the folder it came from and write the file back. The creation date will be the moment it was written.
Michael, out of interest, how are you viewing the Creation Date of the folder?
Works fine here W10. Don’t forget that the default view of explorer is “Date Modified” not “Date created”. If you add the Column into the explorer view you can see the correctly changed creation date. Maybe you’re looking at the wrong data?
I’ve tried several things with no luck. I’m assuming that this is a bug in the build I’m using (REALStudio 2011R1).
The folder is not in use, it is not nil, it does exist and there are no errors generated. Getting the creation date from Windows Explorer. Even added to code pop-up with the creation date in case Explorer was misbehaving. It’s simply not happening.
Letting us know the version at the start might help I can’t test that far back sorry, I don’t have a licence that old, I tested it on 2019r1 and it worked fine.
[quote=437425:@Michael Brogdon]Dim f as FolderItem
f = GetFolderItem(“C:\FolderName”)
Dim newDate As New Date
newDate.Year = 1999
newDate.Month = 9
newDate.Day = 9
f.CreationDate = newDate
[/quote]
Your code works in RS2010r5.1, which is pretty close to the version you’re using. Windows 10.
Well it works for me on my own machine configuration, but fails on the few client configurations that I have. It gets flagged in the logs as a security violation.
Any chance a security issue is causing you issues?
I appreciate that you are still interested in this.
Yesterday I found that I could set the creation date under certain circumstances, but it was the end of the day and I couldn’t see a pattern or cause. It seems that if I reference the parent folder first, then the child folder (the true target), it will work at least sometimes.
I didn’t made it by hand, i thought your program did that. But now i have done it and the message is now:
19:13:09 : My Application.exe Launched
Trying >C:\FolderName<
CreateFileW=316
SetFileTime=1
Cool Andre, that worked, thanks. My code was more for those that have issues with the original not working to see if my rewrite works but thanks for trying
I’ll alter the code and incorporate the original test in it though, thanks for reminding me!