磁盘上的目录大小 [英] Directory size on disk

查看:67
本文介绍了磁盘上的目录大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我希望找到Windows平台上给定目录\文件夹的总空间(在磁盘上)。

有人知道怎么做吗?


谢谢,

Ido。

Hello,
I wish to find out the total space (on disk) of a given directory \ folder on windows platform.
Does anybody know how to do it ?

Thanks,
Ido.

推荐答案

到目前为止你尝试了什么?请发布您用于解决此问题的代码,我们可以从那里获得帮助。


只是提示,您可能希望搜索CPAN以获取您想要的模块。如果你去search.cpan.org并搜索size,你会看到 File :: Size 将返回文件和目录的大小。


问候,


杰夫
What have you tried so far? Please post the code you have used to solve this and we can assist from there.

Just a tip though, you may want to search CPAN for modules to do what you want. If you go to search.cpan.org and search for "size", you will see an entry for File::Size which will return the size of files and directories.

Regards,

Jeff


你好杰夫,

感谢您的回复。


我使用stat函数返回关于给定文件路径的几个参数,其中一个参数保存文件大小。但不幸的是,这个值只是文件的实际大小,而不是它在磁盘上占用的空间。我需要磁盘大小值。


我一直在尝试使用WMI,但它不包含任何大小。目录上的值,仅在文件上(这也是实际大小)。


还有一件事,我试图避免手动深入到文件夹并累积其所有子目录的文件大小(假设我能够找到)他们的磁盘大小值)。


非常感谢,

Ido。
Hello Jeff,
Thanks for your reply.

I used stat function which returns several parameters regarding a given file path, one of which holds the file size. But unfortunately this value is only the actual size of file, not the space it occupies on the disk. I need "size on disk" value.

I have been trying to use WMI as well, but it doesn''t contain any "size" values on directories, just on files (and this is the actual size as well).

One more thing, I am trying to avoid a case of manually drill down into the folder and accumulate all its sub directory''s files size (presuming I will be able to find out their "size on disk" values).

Thanks anyway,
Ido.


好的,你试过我提到的File :: Size模块吗?在我的上一篇文章?另外,要处理文件大小,请尝试文件:: Util 模块,因为它返回文件大小(以字节为单位),根据需要应该是磁盘大小。


只需要对CPAN进行一些搜索。你想处理文件?搜索文件或大小或大小。看看会出现什么。每个模块的详细说明都是给你的评论。


问候,


杰夫
Ok, have you tried the File::Size module that I mentioned in my last post? Also, for dealing with file size, try the File::Util module as it returns the file size in bytes, which should be size on disk as you need.

It just takes a bit of searching on CPAN. You want to deal with files? Search for "file" or "size" and see what comes up. A brief description of what each module does IS given for your review.

Regards,

Jeff


这篇关于磁盘上的目录大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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