FAES/Utilities/FileAES_IntUtilities.cs
/// <summary>
/// Safely deletes a folder by ensure it exists before deletion
/// </summary>
/// <param name="path">Path to folder</param>
/// <param name="recursive">If SafeDeleteFolder should delete contents of the folder</param>
/// <returns>If the folder is deleted</returns>
Safely deletes a folder by ensure it exists before deletion
Safely deletes a folder by ensure it exists before deletion
internal static bool SafeDeleteFolder(string path, bool recursive = true)
        {
            if (Directory.Exists(path))
            {
                try
                {
                    Directory.Delete(path, recursive);
                    Logging.Log($"SafeDeleteFolder: {path}", Severity.DEBUG);
                    return true;
                }
                catch
                {
                    throw new UnauthorizedAccessException("Error occurred in SafeDeleteFolder. Folder cannot be deleted!");
                }
            }
            return false;
        }
internal static bool SafeDeleteFolder ( string path , bool recursive = true ) { if ( Directory . Exists ( path ) ) { try { Directory . Delete ( path , recursive ) ; Logging . Log ( $" SafeDeleteFolder:  { path } " , Severity . DEBUG ) ; return true ; } catch { throw new UnauthorizedAccessException ( " " ) ; } } return false ; }
Safely deletes a folder by ensure it exists before deletion
Safely deletes a folder by ensure it exists before deletion
If the folder is deleted
If the folder is deleted
path
string
Path to folder
Path to folder
recursive
bool
If SafeDeleteFolder should delete contents of the folder
If SafeDeleteFolder should delete contents of the folder