How do I get directory size
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-io' list.


Endys, Miroslav
-- Copied from [aspngcs] to [ngfx-io] by Charles M. Carroll <Click here to reveal e-mail address> --

How do I get a directory size in C#?

Miroslav Endys

Reply to this message...
 
    
Erik Brown
Miroslav,

Do you mean number of files or number of bytes? There are three
methods that might be useful here:

    Directory.GetFiles returns the set of files
    Directory.GetDirectories returns the set of subdirectories
    Directory.GetFileSystemEntries returns the set of files and
subdirectories

You can use the Length property to determine the number of items, or
walk the tree to determine this for an entire subdirectory or to count
the number of bytes.

For example, Directory.GetFiles(path).Length provides the number of
files in the given path.

Erik Brown
Author of "Windows Forms Programming with C#" (www.manning.com/eebrown)

[Original message clipped]

Reply to this message...
 
    
Lasse Johansen
Hi Miroslav

Take a look at the two classe:

System.IO.File
System.IO.Directory

You are able to get all files(path to it) using the GetFiles from class Directory and from that you associate each path with a File instance. Summing the Length property on each instance of the files gives you the Directory size.

Lasse Johansen

----- Original Message -----
From: "Endys, Miroslav" <Click here to reveal e-mail address>
To: "ngfx-io" <Click here to reveal e-mail address>
Sent: Monday, April 29, 2002 7:13 AM
Subject: [ngfx-io] How do I get directory size

[Original message clipped]

Reply to this message...
 
 
System.IO.Directory
System.IO.File




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com