如何在树形视图中查找文件夹的大小 [英] how to find size of folder in tree view

查看:79
本文介绍了如何在树形视图中查找文件夹的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在制作一个asp.net Web应用程序..
我有一个树形视图.在那个树形视图中,我有一些文件夹.每个文件夹中有很多文字和文本文件.
假设我有一个名为 MyDocumen t的文件夹.在我的文档中有很多文件.现在如何显示此文件夹的大小.

hello to all i am making an asp.net web application..
i have a tree view.In that tree view i have some folders.In each folders there are so many word and text file..

suppose i have one folder named as MyDocument ..In my documents there are lot of files ..now how to show the size of this folder.

推荐答案

希望 ASP.NET树视图-具有自定义的树节点 [
Hope ASP.NET Tree View - with customized tree nodes[^]this article from CP might help you.


在这里您可以找到文件夹的整体大小.

Here is how you can find the whole size of the folder.

DirectoryInfo dirInfo=new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));

double fileSize=0;
foreach(FileInfo fi in dirInfo.GetFiles("*.*",SearchOption.AllDirectories))
{
//fileSize will have the total size displayed in bytes
fileSize+=fi.Length;
}


在将文件夹加载到树形视图中时尝试获取文件夹大小(我在这里假设您将使用根目录结构来构建此TreeView某处).
Try to get the folder size when you are loading the folder into the treeview (I am assuming here that you would be building this TreeView using the root directory structure somewhere).


这篇关于如何在树形视图中查找文件夹的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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