473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

An open source drive space viewer

Hi all,

I am looking to make an open source Drive space viewer. One that displays
the sizes in a graph and lets you move through the directories via a
treeview at the left.

I have three questions i hope someone could help with:

1. The problem I have is tallying up the directories and sub
directories. This is made even more complicated by the fact that I need to
allow the user to exclude certain sub directories when doing the
calculations. Does anyone know if there is a class in the framework that, at
the very least, can tell me the size of a folder and its contents.

2. Does anyone have any code or suggestions about how I could handle the
problem of excluding various directories. The user needs to click a tick box
in the treeview to have that dir included

3. Does anyone know of an open source application that I could look at for
this purpose

Thank you everyone

Simon
Jul 21 '05 #1
2 1562
Simon,

1) .NET Framework has two classes that you can use to obtain the
information specific to files and directories. They are: FileInfo and
DirectoryInfo. Unfortunately, there is not a method on the
DirectoryInfo class to return the size of the Directory. I wrote a
little helper class that has a method on it that will return the size
of the directory in bytes. Here it is:

public class FileSystemHelper
{
private FileSystemHelper()
{
}
// returns the size of the given directory in bytes.
public static long GetDirectorySize(DirectoryInfo di)
{
if(di==null)
{
throw new ArgumentNullException("di");
}
long size = 0;
FileInfo[] files = di.GetFiles();
// sum up file size
if(files!=null && files.Length>0)
{
foreach(FileInfo fi in files)
{
size+=fi.Length;
}
}
// sum up dir size
DirectoryInfo[] dirs = di.GetDirectories();
if(dirs!=null && dirs.Length>0)
{
foreach(DirectoryInfo dii in dirs)
{
// recursive call
size+=FileSystemHelper.GetDirectorySize(dii);
}
}
return size;
}

}

You can get to the contents of the directory by calling GetFiles() and
GetDirectories().

2) GetFiles() and GetDirectories() is overloaded to accept a
searchPattern so you can use that to exclude certain
files/directories.

3) I don't know of any open source tools that do this kind of stuff.

sayed

"Simon Harvey" <sh856531@microsofts_free_email_service.com> wrote in message news:<et**************@TK2MSFTNGP15.phx.gbl>...
Hi all,

I am looking to make an open source Drive space viewer. One that displays
the sizes in a graph and lets you move through the directories via a
treeview at the left.

I have three questions i hope someone could help with:

1. The problem I have is tallying up the directories and sub
directories. This is made even more complicated by the fact that I need to
allow the user to exclude certain sub directories when doing the
calculations. Does anyone know if there is a class in the framework that, at
the very least, can tell me the size of a folder and its contents.

2. Does anyone have any code or suggestions about how I could handle the
problem of excluding various directories. The user needs to click a tick box
in the treeview to have that dir included

3. Does anyone know of an open source application that I could look at for
this purpose

Thank you everyone

Simon

Jul 21 '05 #2
On 26 Aug 2004, Simon Harvey wrote:
Hi all,

[...]
3. Does anyone know of an open source application that I could look
at for
this purpose


JDiskReport. Google for it.

Burkhard
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
34
by: Michael Foord | last post by:
I'd like to formalise slightly the license I release my projects under. At the moment it's 'free to use, modify, distribute and relicense'. This is basically fine as I don't want t oprevent people...
5
by: Pete Wason | last post by:
Hiall! I have a demo viewer page for javascript stuff that has three buttons "DEMO" "HTML" and "JSCR", and an IFRAME called 'viewer'. Initially, the IFRAME gets loaded with the actual demo...
0
by: Tom Dacon | last post by:
"Open .Net Command Window Here" context menu for Windows Explorer: The reg file described below adds a new menu item to Windows Explorer's context menu when you right-click over a folder (or the...
9
by: gleverett | last post by:
I have been searching the 'Net, and I can't find the right solution here. I am writing some PHP pages that utilize some Javascript. The script works in Mozilla/Netscape, but fails in IE. I don't...
1
by: Simon Harvey | last post by:
"Simon Harvey" <sh856531@microsofts_free_email_service.com> wrote in message news:... Hi all, I am looking to make an open source Drive space viewer. One that displays the sizes in a graph and...
1
by: Biodigit | last post by:
The DTS works perfectly when I run it manually. However, when I run it as a job it fails. Before you ask if i'm running it under different security context. I have already made sure of that. I was...
24
by: dancer | last post by:
Using ASP.net 1.1 and Microsoft Access. I received the following error message. Why? I have closed the Access file. I have another very small access file that opens with no trouble with the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.