An open source drive space viewer - DOTNET

This is a discussion on An open source drive space viewer - DOTNET ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

An open source drive space viewer

  1. Default 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



  2. Default Re: An open source drive space viewer

    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:<etqxQ52iEHA.2652@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


  3. Default Re: An open source drive space viewer

    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

+ Reply to Thread

Similar Threads

  1. open source tools for browsing CORBA Naming Service space?
    By Application Development in forum Object
    Replies: 2
    Last Post: 06-04-2007, 02:35 AM
  2. open source space civ game: want to help?
    By Application Development in forum Java-Games
    Replies: 18
    Last Post: 10-30-2004, 02:33 PM
  3. Replies: 0
    Last Post: 09-15-2004, 04:01 AM
  4. C:\drive low on space
    By Application Development in forum Microsoft Exchange
    Replies: 1
    Last Post: 11-26-2003, 04:19 PM