@@ -1,5 +1,7 @@ | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | |||||
using System.Security.AccessControl; | |||||
using Alphaleonis.Win32.Filesystem; | using Alphaleonis.Win32.Filesystem; | ||||
namespace NTFSSecurity | namespace NTFSSecurity | ||||
@@ -52,5 +54,10 @@ namespace NTFSSecurity | |||||
throw new System.IO.FileNotFoundException(); | throw new System.IO.FileNotFoundException(); | ||||
} | } | ||||
} | } | ||||
} | |||||
public static List<T> GetListOfNames<T>(this Enum source) | |||||
{ | |||||
return Enum.GetValues(typeof(T)).Cast<T>().ToList(); | |||||
} | |||||
} | |||||
} | } |
@@ -23,7 +23,7 @@ | |||||
<DebugSymbols>true</DebugSymbols> | <DebugSymbols>true</DebugSymbols> | ||||
<DebugType>full</DebugType> | <DebugType>full</DebugType> | ||||
<Optimize>false</Optimize> | <Optimize>false</Optimize> | ||||
<OutputPath>..\..\..\..\..\..\Program Files\WindowsPowerShell\Modules\NTFSSecurity\</OutputPath> | |||||
<OutputPath>..\..\..\..\Documents\WindowsPowerShell\Modules\NTFSSecurity\</OutputPath> | |||||
<DefineConstants>TRACE;DEBUG</DefineConstants> | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||||
<ErrorReport>prompt</ErrorReport> | <ErrorReport>prompt</ErrorReport> | ||||
<WarningLevel>4</WarningLevel> | <WarningLevel>4</WarningLevel> | ||||
@@ -1,5 +1,6 @@ | |||||
using Alphaleonis.Win32.Filesystem; | using Alphaleonis.Win32.Filesystem; | ||||
using System; | using System; | ||||
using System.Linq; | |||||
using System.Security.AccessControl; | using System.Security.AccessControl; | ||||
namespace Security2 | namespace Security2 | ||||
@@ -99,14 +100,26 @@ namespace Security2 | |||||
public void Write() | public void Write() | ||||
{ | { | ||||
if (isFile) | |||||
var values = Enum.GetValues(typeof(System.Security.AccessControl.AccessControlSections)); | |||||
foreach (var value in values) //.Cast<string>().Where(v => v != "All" | v != "None")) | |||||
{ | { | ||||
((FileInfo)item).SetAccessControl((FileSecurity)sd); | |||||
} | |||||
else | |||||
{ | |||||
((DirectoryInfo)item).SetAccessControl((DirectorySecurity)sd); | |||||
try | |||||
{ | |||||
if (isFile) | |||||
{ | |||||
((FileInfo)item).SetAccessControl((FileSecurity)sd, (AccessControlSections)value); | |||||
} | |||||
else | |||||
{ | |||||
((DirectoryInfo)item).SetAccessControl((DirectorySecurity)sd, (AccessControlSections)value); | |||||
} | |||||
} | |||||
catch | |||||
{ | |||||
//Console.WriteLine("Exception {0} - {1}", item.FullName, value); | |||||
} | |||||
} | } | ||||
} | } | ||||
public void Write(FileSystemInfo item) | public void Write(FileSystemInfo item) | ||||
@@ -15,6 +15,17 @@ namespace TestClient | |||||
{ | { | ||||
static void Main(string[] args) | static void Main(string[] args) | ||||
{ | { | ||||
//List<AccessControlSections> fileSystemRights = new List<AccessControlSections>(); | |||||
//var values = Enum.GetValues(typeof(AccessControlSections)).Cast <AccessControlSections>().ToList(); | |||||
//var v1 = values.Where(v => v == AccessControlSections.All).FirstOrDefault | |||||
var x = Enum.get | |||||
var item1 = new FileInfo("D:\\file1.txt"); | var item1 = new FileInfo("D:\\file1.txt"); | ||||
var item2 = new DirectoryInfo("D:\\test3"); | var item2 = new DirectoryInfo("D:\\test3"); | ||||
var account1 = new List<IdentityReference2>() { (IdentityReference2)@"raandree1\randr_000" }; | var account1 = new List<IdentityReference2>() { (IdentityReference2)@"raandree1\randr_000" }; | ||||