giving a user ALL_ACCESS to a file/directory

A

Aryeh Katz

I'd like to set the permissions on a file (directory) so that a user (and
only that user) is granted full control for that file.
Using c++, I was able to use the BuildExplicitAccessWithName, and
SetEntriesInAcl calls.
Is there a native c# way to do this?

Aryeh
 
N

Nicholas Paldino [.NET/C# MVP]

Aryeh,

These APIs are not represented in .NET. You will have to make the calls
to the native code through the P/Invoke layer.

Hope this helps.
 
A

Aryeh Katz

Aryeh,

These APIs are not represented in .NET. You will have to make the calls
to the native code through the P/Invoke layer.
I read that doing the ACL to c# conversion is very tricky in
the "Using Win32 and Other Libraries" article by Eric Gunnerson.
(I see now that the example he gives is SetEntriesInAcl. Silly me).
I guess my best hope is to launch a c++ program that I already
wrote that does this task.
Hope this helps.
Thank you.
Aryeh
 
N

Nicholas Paldino [.NET/C# MVP]

Aryeh,

If you already have code in C++ that does it, you could create managed
wrappers, or expose the C++ code as a COM object, and then import those into
..NET.
 
A

Aryeh Katz

Aryeh,

If you already have code in C++ that does it, you could create managed
wrappers, or expose the C++ code as a COM object, and then import those into
.NET.
Shrug.
The code base I'm working with is quite small, and is part of a
standalone executable.
I suppose I could make it into a dll, and use managed wrappers, but
what's the point?
Why shouldn't I just invoke the executable?
Aryeh
P.S. As I'm new to c#, do you have any good articles about invoking
a com interface in c# and managed wrappers. I've been too busy problem
solving to actually have a go at some documentation (Bad, I know.)
 
N

Nicholas Paldino [.NET/C# MVP]

Aryeh,

You could make a call out to the executable, but you promote code reuse
and good design by exposing it as a library of classes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top