Show / Hide Table of Contents

Method filesystem.more.calculateDirectorySize


Overload

Calculates the sum of all descendant file sizes. With default flags, it includes sizes of all descendant files, in this directory and all subdirectories except in inaccessible [sub]directories.

public static long calculateDirectorySize(string path, FLFlags flags = FLFlags.Recurse | FLFlags.IgnoreInaccessible)
Parameters
path  (string)

Full path.

flags  (FLFlags)

Enum: Recurse, RecurseFollowLinks, SkipHidden, SkipHiddenSystem, IgnoreInaccessible.

Returns
long
Exceptions
Exception

Exceptions of FLQuery.Enumerate. No exceptions if used default flags, full path and the directory exists.

Remarks

This function is slow if the directory is large. For drives use System.IO.DriveInfo instead; it's fast and includes sizes of Recycle Bin and other protected hidden system directories.