问题描述
我可以使用NSFileManager在Mac OS X 10.5和10.6的 / Library / Application Support中创建XYZ文件夹。但是,在10.7中,它说您无权将XYZ保存在文件夹 Application Support中。。
I can use NSFileManager to create a XYZ folder in "/Library/Application Support" in Mac OS X 10.5 and 10.6. However, in 10.7, it says "You don't have permission to save XYZ in the folder 'Application Support'".
有人知道我可以做什么(例如,调用哪个API)以获取创建文件夹的权限?谢谢。
Does anyone know what I can do (e.g. which API to call) to get that permission to create the folder? Thanks.
推荐答案
您是否正在使用沙箱?如果是这样,则说明您写到了错误的地方。无论哪种情况,您都应该使用 NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,NSUserDomainMask,YES)
来找到正确的路径,而不是对其进行硬编码。
Are you using sandboxing? If so, you’re writing to the wrong place. In either case, you should be using NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)
to find the right path rather than hard-coding it.
这篇关于写入“〜/库/应用程序支持”; Mac OS X 10.7中的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!