Get Folder Attributes
-
How can I get the folder information, such as size size on disk contains 900 files, 7 folders really all I am looking for in the contains part. **DAN**:)
-
How can I get the folder information, such as size size on disk contains 900 files, 7 folders really all I am looking for in the contains part. **DAN**:)
You can obtain number of files and folders from instance of DirectoryInfo class. According to me the size of folder you will have to count yourself. For example:
using System; using System.IO; namespace size { class Class1 { [STAThread] static void Main(string[] args) { DirectoryInfo dir = new DirectoryInfo(@"C:\Sybila"); long size = 0; size += GetSizeOfDirectory(dir); Console.WriteLine(String.Format("Size of folder {0}", size)); } protected static long GetSizeOfDirectory(DirectoryInfo dir) { long ret = 0; foreach(FileInfo fi in dir.GetFiles()) { ret += fi.Length; } foreach(DirectoryInfo di in dir.GetDirectories()) { ret += GetSizeOfDirectory(di); } return ret; } } }
You would obtain the physical size on the disk with WMI... Tomas Rampas ------------------------------ gedas CR s.r.o. System analyst, MCSD TGM 840, 293 01 Mlada Boleslav, Czech Republic Telefon/phone +420(326)711411 Telefax/fax +420(326)711420 rampas@gedas.cz http://www.gedas.com/ ------------------------------ To be or not to be is true... George Bool