Access Control List in .net

VB.NET:

Imports System.Security.AccessControl
Imports System.Security.Policy
Imports System.Security.Principal
Imports System.IO
Module Module1

    
Sub Main()
        
Dim ds As New DirectorySecurity
        ds.AddAccessRule(
New FileSystemAccessRule("Guest", FileSystemRights.Read, AccessControlType.Allow))
        Directory.CreateDirectory(
"c:\Guest", ds)
        File.Create(
"c:\Guest\Data.Data")
    
End Sub

End Module


C#:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.AccessControl;
using System.Security.Policy;
using System.Security.Principal;
using System.IO;

namespace AccessControlListCS
{
    
class Program
    {
        
static void Main(string[] args)
        {
            DirectorySecurity ds 
= new DirectorySecurity();
            ds.AddAccessRule(
new FileSystemAccessRule("Guest", FileSystemRights.Read, AccessControlType.Allow));
            Directory.CreateDirectory(
@"c:\Guest", ds);
            File.Create(
@"c:\Guest\Data.Data");
        }
    }
}

 

posted @ 2009-05-18 12:52  N/A2011  阅读(232)  评论(0编辑  收藏  举报