I have a list which is full of file path, I’m using FileInfo to get information like createtime, size…
Right now I need to obtain file’s NTAccount and SIDs, so far I’m using the following code to get them, but it seems very slow when the list have large amount of files, say 360,000 files costs me 6′, but if i don’t use these codes, the program only costs me 1′30″.
So is there anyway to imporove it?
Codes:
System.Security.AccessControl.DirectorySecurity directorySecurity = Directory.GetAccessControl(directoryPath);
System.Security.Principal.IdentityReference account = directorySecurity.GetOwner(typeof(System.Security.Principal.NTAccount));
System.Security.Principal.IdentityReference accountsid = directorySecurity.GetOwner(typeof(System.Security.Principal.SecurityIdentifier));
ownerName = account.Value;
ownerSid = accountsid.Value;
Regards