简体   繁体   English

沙盒应用程序:检索文件夹大小(MB / GB)

[英]Sandboxed Application: Retrieve a folders size in MB/GB

I would like to find the size of a given path in MB/GB. 我想找到给定路径的大小(MB / GB)。 I have tried before with NSFileManager but every result would turn out zero because of the app sandboxing (frustrating). 我之前尝试过使用NSFileManager,但是由于应用沙箱(令人沮丧),每个结果都将为零。 Is there a method which works? 有没有可行的方法? I want to find the size of a hidden folder. 我想找到一个隐藏文件夹的大小。

Thanks in advance. 提前致谢。

Is it a path where you don't have access to by default, like user's home folder? 是默认情况下您无权访问的路径,例如用户的主文件夹? Then you need to request access to it from the user by showing her standard open dialog (NSPanel). 然后,您需要通过显示用户的标准打开对话框(NSPanel)来请求用户对其进行访问。 If you want to retain this access between launches, you need to generate and store security-scoped bookmark to that location. 如果要在两次启动之间保留此访问权限,则需要生成安全范围的书签并将其存储到该位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM