An open source drive space viewer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Harvey

    #1

    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


  • Sayed Hashimi

    #2
    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 FileSystemHelpe r
    {
    private FileSystemHelpe r()
    {
    }
    // returns the size of the given directory in bytes.
    public static long GetDirectorySiz e(DirectoryInfo di)
    {
    if(di==null)
    {
    throw new ArgumentNullExc eption("di");
    }
    long size = 0;
    FileInfo[] files = di.GetFiles();
    // sum up file size
    if(files!=null && files.Length>0)
    {
    foreach(FileInf o fi in files)
    {
    size+=fi.Length ;
    }
    }
    // sum up dir size
    DirectoryInfo[] dirs = di.GetDirectori es();
    if(dirs!=null && dirs.Length>0)
    {
    foreach(Directo ryInfo dii in dirs)
    {
    // recursive call
    size+=FileSyste mHelper.GetDire ctorySize(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@micro softs_free_emai l_service.com> wrote in message news:<etqxQ52iE HA.2652@TK2MSFT NGP15.phx.gbl>. ..[color=blue]
    > 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[/color]

    Comment

    • Burkhard Perkens-Golomb

      #3
      Re: An open source drive space viewer

      On 26 Aug 2004, Simon Harvey wrote:
      [color=blue]
      > Hi all,
      >[/color]

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

      JDiskReport. Google for it.

      Burkhard

      Comment

      Working...