views:

33

answers:

0

Hi All,

I am running the following lines of code (C#) on a Windows XP platform:

        DirectoryInfo folder = new DirectoryInfo(this.FullName);
        DirectorySecurity dirSecurity = folder.GetAccessControl();

where this.FullName is the C:\ folder.

And I get the following exception:

Exception : The supplied handle is invalid. This can happen when trying to set an ACL on an anonymous kernel onject.

  1. My user id is VerusUser
  2. I can manually create folders in C:\ using this userid
  3. I cannot programmtically create folders in C:\ with this userid without getting the above exception
  4. I gave VerusUser Full Control to C:\ via the Properties\Advance\Permissions tab and I no longer received the exception i.e. everything worked fine.
  5. When I deleted VerusUser from the Properties\Advance\Permissions tab everything still worked fine i.e. I didn't receive an exception.

Can somebody explain:

  1. Why I'm receiving the exception and what is the best solution?
  2. Why I no longer receive the exception after I remove VerusUser from the Permissions tab?

Thanks,

Peter C