Find out "Owner" of a file as displayed by Windows Explorer
Mostrar comentarios más antiguos
I've seen some files on the FEX that allow you to get creation date / last modified date of a particular file
but does anybody know how to get the name of the "Owner" of a file? (Which is another thing displayed by Windows Explorer so it has to be accessible somehow??)
3 comentarios
Jan
el 8 de Jun. de 2012
Where do you see the owner in the Windows explorer? Do you mean: Context menu -> Properties -> Security -> Advanced -> Owner?
Darin McCoy
el 8 de Jun. de 2012
Jan
el 9 de Jun. de 2012
Thanks, Darin! Now I understand where you find the owner.
Respuesta aceptada
Más respuestas (2)
Jan
el 9 de Jun. de 2012
You can use .NET:
finfo = System.IO.FileInfo(FileName);
dummyAccount = System.Security.Principal.NTAccount('dummy');
Owner = char(finfo.GetAccessControl.GetOwner(GetType(dummyAccount)).Value.ToString);
There must be a more direct method to get the NTAccount type instead of creating a dummy account.
The Windows API methods are not trivial and I hesitate to implement them in a function similar to GetFileTime.
2 comentarios
Darin McCoy
el 11 de Jun. de 2012
Jan
el 11 de Jun. de 2012
The .NET method includes the host name also, such that file owners of network drives are identified uniquely. The DIR approach does not handle this and demands for a complicated parsing of a text file.
scivision
el 18 de Sept. de 2024
The owner of a file can be found using built-in Java
owner = string(java.nio.file.Files.getOwner(java.io.File(path).toPath(), java.nio.file.LinkOption.values));
Categorías
Más información sobre Software Development en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!