From 456a8f74f967afce810274c7a91f3aaddf751e2a Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 11 Feb 2021 11:43:18 -0500 Subject: [PATCH] feat: Adding shim for setting file attributes recursively --- ICD.Common.Utils/IO/IcdFile.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ICD.Common.Utils/IO/IcdFile.cs b/ICD.Common.Utils/IO/IcdFile.cs index 14c997e..890a64b 100644 --- a/ICD.Common.Utils/IO/IcdFile.cs +++ b/ICD.Common.Utils/IO/IcdFile.cs @@ -120,5 +120,18 @@ namespace ICD.Common.Utils.IO { File.Move(sourceFileName, destFileName); } + +#if STANDARD + public static void SetAttributes(string path, FileAttributes attributes, bool recursive) + { + File.SetAttributes(path, attributes); + + if (!recursive || !Directory.Exists(path)) + return; + + foreach (string innerPath in Directory.GetFileSystemEntries(path)) + SetAttributes(innerPath, attributes, true); + } +#endif } }