Notifications
Clear all

[Closed] Get file owner

I wanted to get the owner of an external file inside maxscript. Is that possible? I can see one can use “getFileAttribute”, “getFileSize”, and other things, but not get the owner of the file?
Any suggestions please.

6 Replies

by ‘owner’, do you mean the ‘author’ in the file’s Summary info?

If so, see the ‘3ds Max Scene File Properties’ topic; that only applies to the currently open 3ds Max scene file, however.

For DLLs, EXEs, etc. you could use .net’s “System.Diagnostics.FileVersionInfo”

For Summary Info on arbitrary files, it looks like you might be in a bit of a pickle – might be a .net assembly out there that gives easy access

By “owner”, i mean the person who owns permissions to the file, or the one who created it. It doesn’t have to be a max file.

o_O

okay…


fn getFileOwner f = (
	local fileInfo = dotNetObject "System.IO.FileInfo" f
	local fileAccessControl = fileInfo.getAccessControl()
	local NTAccountType = dotNetClass "System.Security.Principal.NTAccount"
	local fileOwner = fileAccessControl.getOwner NTAccountType
	fileOwner.value
)

example usage:


f = "c:\\divx.log"
"c:\divx.log"
getFileOwner f
"Everyone"

 JHN

And while your at it, please lock this file for others, make a revision copy in a maxscript based versioning system and have it work network wide… in 10 lines of code… but don’t worry it only has to be done by afternoon tomorrow, so plenty of time I reckon!

-Johan

1 Reply
(@zeboxx2)
Joined: 11 months ago

Posts: 0

Done!

It can be all yours for the minor sum of… puts pinkie to mouth

I think there was another thread here somewhere about locking files – I don’t think that went anywhere, did it?

MaxScript -does- have a versioning system added via CVS/Subversion and such, so you could leverage that… if it were available as a function somewhere… I’m only seeing it as a menu option. But I guess you can always call the version control software manually

10 lines is the easy part – as long as you allow ;

Thanks zeboxx. Problem solved. Thanks guys, for all your posts.