设置在Cocoa中修改文件的日期 [英] Set date modified of files in Cocoa

查看:114
本文介绍了设置在Cocoa中修改文件的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Cocoa中设置文件的日期修改属性?感谢

How can I set the date modified attribute of a file in Cocoa? Thanks

推荐答案

NSFileManager setAttributes: ofItemAtPath:error:方法?

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

属性是字典。您可以使用 NSFileModificationDate 键设置修改日期值。

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

基本上:

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

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

这篇关于设置在Cocoa中修改文件的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆