folder owner properties

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the following code to get the properties of a folder and
everything is working ok but I need to find the "Current owner of this item"
for the specified folder.

Dim fileprops As FileInfo = New FileInfo(textbox2.Text)
CheckedListBox2.Items.Add(fileprops.CreationTime)

Any ideas? Thanks,
 
Jason said:
I am using the following code to get the properties of a folder and
everything is working ok but I need to find the "Current owner of this item"
for the specified folder.

Dim fileprops As FileInfo = New FileInfo(textbox2.Text)
CheckedListBox2.Items.Add(fileprops.CreationTime)

This depends on whether you use .NET 1 or .NET 2. In .NET 1, there's on
direct support for this and you have to use WMI to get to the
information. This has been covered in newsgroup posts many times, for
example at this Google Groups link: http://tinyurl.com/9sdam

If you use .NET 2, you can query the information directly, like this:

DirectoryInfo directoryInfo = new DirectoryInfo(@"c:\Windows");
DirectorySecurity directorySecurity =
directoryInfo.GetAccessControl(AccessControlSections.Owner);
IdentityReference identityReference =
directorySecurity.GetOwner(typeof(NTAccount));

Now you have the readable name of the user/group account in
identityReference.Value.

Hope this helps!



Oliver Sturm
 
Back
Top