FLEX:获取文件夹大小 [英] FLEX: getting a folder size

查看:220
本文介绍了FLEX:获取文件夹大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var FolderFile:File = new File(file: /// SomePath /文件夹); 
var FolderSize:FolderFile.size;

但是,这给了我一个值为0,如何获得文件夹大小?有没有反正这样做?



Tranks

解决方案

没有办法做到这一点automagically。获取目录的大小是一个复杂的,可能是痛苦的慢操作。目录中可能有成千上万个文件,或者一个目录可能位于(慢速)网络上,更不用说磁带存储和类似的情况了。

文件系统本身并不存储目录大小信息,唯一的方法就是逐个文件地计算它,没有快捷方式。所以,你将不得不依靠你上面发布的解决方案,是的,这将是缓慢的。


I'm triying to get a folder size by doing:

var FolderFile:File = new File("file:///SomePath/Folder");
var FolderSize: FolderFile.size;

But this gives me a value of 0, how can I get the folder size? is there anyway to do this?

Tranks

解决方案

No, there's no way to do it automagically. Getting the size of the directory is a complex and potentially painfully slow operation. There could be 10s of thousands of files in a directory, or a directory could be located on a (slow?) network, not to mention tape storage and similar scenarios.

The file systems themselves don't store directory size information, and the only way to know it is to calculate it file-by-file, there's no quick/easy shortcut. So, you will have to rely on the solution you posted above, and, yes, it is going to be slow.

这篇关于FLEX:获取文件夹大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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