Skip to content

Commit

Permalink
Merge pull request #6 from Rans4ckeR/master
Browse files Browse the repository at this point in the history
Delete directories recursively
  • Loading branch information
Rampastring authored Sep 26, 2022
2 parents fa43ed8 + e647843 commit c894bc8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions SafePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static FileInfo GetFile(params string[] paths)

/// <summary>
/// Safely delete a file represented by multiple directory paths with a file name for all platforms.
/// If the file does not exist the delete operation is not performed.
/// Does not throw an exception if the file or directory path does not exist.
/// </summary>
/// <param name="paths">Ordered list of directory paths with a file name.</param>
public static void DeleteFileIfExists(params string[] paths)
Expand All @@ -69,15 +69,16 @@ public static void DeleteFileIfExists(params string[] paths)

/// <summary>
/// Safely delete a directory represented by multiple directory paths for all platforms.
/// If the directory does not exist the delete operation is not performed.
/// Does not throw an exception if the directory path does not exist.
/// </summary>
/// <param name="recursive">true to remove directories, subdirectories, and files in path; otherwise, false.</param>
/// <param name="paths">Ordered list of directory paths.</param>
public static void DeleteDirectoryIfExists(params string[] paths)
public static void DeleteDirectoryIfExists(bool recursive, params string[] paths)
{
var directoryInfo = new DirectoryInfo(CombineFilePath(paths));

if (directoryInfo.Exists)
directoryInfo.Delete();
directoryInfo.Delete(recursive);
}

/// <summary>
Expand Down

0 comments on commit c894bc8

Please sign in to comment.