如何检查文件和文件夹的总数# [英] How to check total # of files and folders

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

问题描述

主题说明如何检查特定文件夹中的文件和文件夹总数,并确定该文件夹的总大小。我将使用VB.NET。一个小的代码片段会很棒。

谢谢

As the subject says how can I check total # of files and folders in a particular folder and determine the total size of that folder. I will be using VB.NET. A small code snippet will be great.
Thanks

推荐答案

没有代码片段,但有一个解释:


为了做到这一点,你需要使用System.IO命名空间,因此对于VB.NET,你需要将Imports System.IO放在页面的最顶层。


对你最有用的两个对象是 DirectoryInfo FileInfo的的。 DirectoryInfo可以获取特定目录中的所有文件和所有目录。但是,这只会达到最高水平。如果要获取所有子目录中的所有文件,则需要编写递归函数。如果你不熟悉它,你应该查找递归。递归是一个棘手但非常重要的学习概念。


如果您需要更多帮助,请告诉我。
No code snippet, but an explanation:

To do this right, you need to use the System.IO namespace, so for VB.NET, you need to put Imports System.IO at the very top of the page.

The two objects that will be most useful to you are DirectoryInfo and FileInfo. DirectoryInfo can get all files and all directories in a particular directory. However, this will only get the top level. If you want to get all the files in all the subdirectories, you will need to write a recursive function. You should look up recursion if you aren''t familiar with it. Recursion is a tricky but very important concept to learn.

Let me know if you need any more help.



没有代码片段,但有一个解释:


要做到这一点,你需要使用System.IO命名空间,所以对于VB.NET,你需要把Imports System.IO放在页面的最顶层。


对你最有用的两个对象是 DirectoryInfo FileInfo 。 DirectoryInfo可以获取特定目录中的所有文件和所有目录。但是,这只会达到最高水平。如果要获取所有子目录中的所有文件,则需要编写递归函数。如果你不熟悉它,你应该查找递归。递归是一个棘手但非常重要的学习概念。


如果您需要更多帮助,请告诉我。
No code snippet, but an explanation:

To do this right, you need to use the System.IO namespace, so for VB.NET, you need to put Imports System.IO at the very top of the page.

The two objects that will be most useful to you are DirectoryInfo and FileInfo. DirectoryInfo can get all files and all directories in a particular directory. However, this will only get the top level. If you want to get all the files in all the subdirectories, you will need to write a recursive function. You should look up recursion if you aren''t familiar with it. Recursion is a tricky but very important concept to learn.

Let me know if you need any more help.



感谢您的帮助。实际上我曾经是一年前的开发人员,现在我在基础设施,所以我有点忘记了这些东西。我知道如何使用递归循环,我将使用它。所有我需要知道如何获得根文件夹的大小。

Thanks for the help. Actually I used to be a developer one year ago, now I am in infrastructure, so I am kinda forgetting the stuff. I know how to use recursive loop, I will use that. All I need to know how to get the size of the root folder.



感谢您的帮助。实际上我曾经是一年前的开发人员,现在我在基础设施,所以我有点忘记了这些东西。我知道如何使用递归循环,我将使用它。我需要知道如何获取根文件夹的大小。
Thanks for the help. Actually I used to be a developer one year ago, now I am in infrastructure, so I am kinda forgetting the stuff. I know how to use recursive loop, I will use that. All I need to know how to get the size of the root folder.



嗯,这就是问题所在。您无法获得根文件夹大小而无需递归遍历所有子目录,获取所有文件并添加其大小。


希望有所帮助。

Well, that''s the thing. You can''t get the root folder size without recursively looping through all the subdirs, getting all the files and adding up their sizes.

Hope that helps.


这篇关于如何检查文件和文件夹的总数#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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