开发者

Set date modified of files in Cocoa

How can I set the da开发者_运维知识库te modified attribute of a file in Cocoa? Thanks


What about NSFileManager setAttributes:ofItemAtPath:error: method?

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html

Attributes are a dictionary. You can set a modification date value with the NSFileModificationDate key.

Basically:

NSDictionary* attr = [NSDictionary dictionaryWithObjectsAndKeys: yourDate, NSFileModificationDate, NULL];

[[NSFileManager defaultManager] setAttributes: attr ofItemAtPath: yourPath error: NULL];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜