得到文件的所有者

using System;
using System.IO;
using System.Security.AccessControl;
using System.Security.Principal;

namespace ConsoleApplication2
{
    class Program
    {
    
        static void Main(string[] args)
        {
            FileInfo fi = new FileInfo(@"c:\1.txt");
            FileSecurity fs = fi.GetAccessControl();
            IdentityReference ir = fs.GetOwner(typeof(NTAccount));
            Console.Write(ir.Value);

        }
    }
}


posted on 2007-02-14 17:20  stswordman  阅读(284)  评论(0编辑  收藏  举报