views:

139

answers:

4

How can I launch the standard file permissions dialog from a .NET application? Can't seem to find any example of this anywhere. I don't want to programmatically set file permissions, I want to let a user set them via the dialog.

+1  A: 

I don't think that there is a wrapper in Winforms that wraps that dialog, it would be simple enough to create your own dialog though, you need to call the SetAccessControl method from the FileInfo class, there is an example here

http://msdn.microsoft.com/en-us/library/system.io.fileinfo.setaccesscontrol.aspx

Tim Jarvis
As I said, I don't want to set them myself. I already know how to do that. I want to launch the operating system dialog.
A: 

The Shell API (IShellFolder) might be a way to do this, if you can find out which verb will open the security dialog for a file. I just tried writing a script to list the verbs available on a file, and the closest thing I could see was "Properties" which would show all the property pages, not just security. Also when I tried to invoke the verb, nothing happened. So not much of an answer, I admit, but maybe it will be a starting point.

Daniel Earwicker
+1  A: 

Found the answer here:

http://www.pluralsight.com/community/blogs/keith/archive/2004/10/04/2636.aspx

Mark your answer here as solved, if you would :)
Valentein
A: 

And another easier method:

BOOL SHObjectProperties( HWND hwndOwner, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage );