locked
Accessing folders: My Music, My Video, etc programmaically. RRS feed

  • Question

  • It came to my attention while I was doing a routine inventory of all dlll files on one of my machines. I've decided to collect all directories that failed the access. I therefore built an xml file where each directory that failed to have been accessed is stored. Altogether I now have 39 directories, perhaps out of 150,000 or so that could not be accessed. I really don't care about any of them as far as my primary task goes. Even some of the systems directories, like Windows Defender, are not something where I would be looking for dlls.

     

    What struck me was that under no circumstances could I access some of the most innocuous directories

     

    C:\users\alex\documents\my photos\

    C:\users\alex\documents\my music\ etc.

     

    The typical message is: "Access to the path 'C:\Users\Alex\Documents\My Pictures' is denied."

     

    The code I am using for creating ACL is:

     

    Code Snippet

    try

    {

    System.Security.AccessControl.DirectorySecurity sec = System.IO.Directory.GetAccessControl ( dir );

    FileSystemAccessRule accRule = new FileSystemAccessRule ( identityString, FileSystemRights.FullControl,   AccessControlType.Allow );

    sec.AddAccessRule ( accRule );

    Dir = System.IO.Directory.GetDirectories ( dir );dirQue = saveFileInfo ( Dir, dirQue, ext, Globals.hostName );

    }

     

     

     

    I began with softer permission attributes: ListDirectory and then Read. It was the same thing. FullRights did not do nothing. Needless to say I run the app as administrator.

     

    I'm kind of wondering if I should perhaps store my pictures in a separate directory custom created in case I need to do an inventory which may one day come but not soon.

     

    Why is it so?

     

    Thanks.

     

     

    Thursday, July 31, 2008 11:49 AM