src/SyncTool.Utilities/main/DirectoryHelper.cs
/// <summary>
/// Removes all items from the specified directory recursively if it exists. If files within the directory are write-protected
/// the protection will be removed and the will will be deleted anyways
/// </summary>
Removes all items from the specified directory recursively if it exists. If files within the directory are write-protected
the protection will be removed and the will will be deleted anyways
Removes all items from the specified directory recursively if it exists . If files within the directory are write - protected the protection will be removed and the will will be deleted anyways
public static void ClearRecursively(string directoryPath)
        {
            if (!Directory.Exists(directoryPath))
            {
                return;
            }
            var directoryInfo = new DirectoryInfo(directoryPath);                   
            foreach (var dir in directoryInfo.GetDirectories())
            {
                DeleteRecursively(dir.FullName);
            }
            foreach (var info in directoryInfo.GetFiles())
            {
                info.Attributes = FileAttributes.Normal;
                info.Delete();
            }
        }
public static void ClearRecursively ( string directoryPath ) { if ( ! Directory . Exists ( directoryPath ) ) { return ; } var directoryInfo = new DirectoryInfo ( directoryPath ) ; foreach ( var dir in directoryInfo . GetDirectories ( ) ) { DeleteRecursively ( dir . FullName ) ; } foreach ( var info in directoryInfo . GetFiles ( ) ) { info . Attributes = FileAttributes . Normal ; info . Delete ( ) ; } }
Removes all items from the specified directory recursively if it exists.
Removes all items from the specified directory recursively if it exists .
// if the directory dows not exist, we can return right away
directoryPath
string