From b372b2736cd51898c61c02d62d066085720c6e9b Mon Sep 17 00:00:00 2001 From: samuel-lucas6 <63159663+samuel-lucas6@users.noreply.github.com> Date: Sun, 4 Jul 2021 15:13:52 +0100 Subject: [PATCH] FileHandling.cs: Add IsDirectoryEmpty() function. --- src/KryptorCLI/GeneralPurpose/FileHandling.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/KryptorCLI/GeneralPurpose/FileHandling.cs b/src/KryptorCLI/GeneralPurpose/FileHandling.cs index d2f1f45..1b4bdef 100644 --- a/src/KryptorCLI/GeneralPurpose/FileHandling.cs +++ b/src/KryptorCLI/GeneralPurpose/FileHandling.cs @@ -1,6 +1,7 @@ using Sodium; using System; using System.IO; +using System.Linq; /* Kryptor: A simple, modern, and secure encryption tool. @@ -51,6 +52,11 @@ public static bool IsDirectory(string filePath) return fileAttributes.HasFlag(FileAttributes.Directory); } + public static bool IsDirectoryEmpty(string directoryPath) + { + return !Directory.EnumerateFileSystemEntries(directoryPath).Any(); + } + public static string[] GetAllDirectories(string directoryPath) { return Directory.GetDirectories(directoryPath, "*", SearchOption.AllDirectories);