This is a mirror of official site: http://jasper-net.blogspot.com/

Retrieve Security Information of Files using .NET

| Sunday, June 20, 2010
The System.Security.AccessControl namespace provides programming elements to control access to and audit security-related actions on securable objects. In this article, we will see how to display security information of files kept in a directory.  

Step 1: Our first step is to loop through all the files in the Directory. With .NET 4.0, it becomes easier to enumerate directories and files. Read my blogpost on  7 New methods to Enumerate Directory and Files in .NET 4.0. We will use the DirectoryInfo.EnumerateFiles which returns an enumerable collection of file information in the current directory as shown below:

string dirLocation = @"C:\Program Files\IIS\Microsoft Web Deploy\";
// IEnumerable<FileInfo> new to .NET 4.0
var fileInfo = new DirectoryInfo(dirLocation).EnumerateFiles();

foreach (var file in fileInfo)
{
}

Read more: Net curry net

Posted via email from .NET Info

0 comments: