# VBForums CodeBank > CodeBank - C# >  C# - Size of Folder in Bytes (Deep or Shallow)

## SimonVega

```
using System;
using System.IO;

public class Folder {
    private static double sizeInBytes; 

    public static double Size(string directory, bool deep) {
        DirectoryInfo dir = new DirectoryInfo(directory);
        foreach(FileInfo f in dir.GetFiles()) {
            sizeInBytes += f.Length;
        }
        if(deep) {
            foreach(DirectoryInfo d in dir.GetDirectories()) {
                Size(d.FullName, deep);
            }
        }
        return sizeInBytes;
    }

    static void Main() {
        Console.WriteLine("The total folder size in bytes is {0}",  Folder.Size(@"c:\sonysys", true));
    }
}
```

----------

