none
Directory Config.Msi RRS feed

  • Question

  • Hi  I have a method that traverses directories and I am getting exceptions

    Access to the path 'C:\Config.Msi' is denied.
    Access to the path 'C:\Documents and Settings' is denied.
    Access to the path 'C:\MSOCache' is denied.
    Access to the path 'C:\Recovery' is denied.
    Access to the path 'C:\System Volume Information' is denied.

    Note the first one:

    Access to the path 'C:\Config.Msi' is denied. But I cannot find this directory in the C drive where it is telling me. Can some one explain this to me.

    this is my code: it is not complete yet

     public static void GetDrivesAndDirectoriesAndFiles()
            {
    
                StringBuilder exceptions = new StringBuilder();
                    DriveInfo[] allDrives = DriveInfo.GetDrives();
                
                Queue<DriveInfo> DrivQ = new Queue<DriveInfo>(allDrives);
                while(DrivQ.Count()>0)
                {
                    var drive = DrivQ.Dequeue();
                    if (!drive.IsReady)
                    {
                        break;
                    }
                    //Console.WriteLine("Drive: " + drive.Name);
                    DirectoryInfo[] rootDirs = null;
                    Queue<DirectoryInfo> dirQ = null;
                    try
                    {
                         rootDirs = drive.RootDirectory.GetDirectories();
                        //Console.WriteLine(" directories in: " +  drive.RootDirectory.Name);
                       dirQ = new Queue<DirectoryInfo>(rootDirs);
                    }
                    catch { }
                    while (dirQ.Count() > 0)
                    {
                        var dir = dirQ.Dequeue();
                        //Console.WriteLine(" directory: "+dir.Name);
                        FileInfo[] files = null;
                        Queue<FileInfo> fileQ = null;
                        try
                        {
                             files = dir.GetFiles();
    
                             fileQ = new Queue<FileInfo>(files);
                           // Console.WriteLine("Files in dir: " + dir.Name);
                       
                        
                        
                            while (fileQ.Count() > 0)
                            {
                                var file = fileQ.Dequeue();
                               
                                    //Console.WriteLine(file.Name);// " : " + file.GetType().Name);
                                
                            }
                        
                        }
                        catch (Exception ex) {
                            exceptions.Append(ex.Message+"\n");
                        }
    
    
    
    
                    }
                    
                        
                    }
    
                System.Diagnostics.Debug.WriteLine(exceptions.ToString()); 
            }

    Saturday, June 8, 2019 2:43 PM

Answers

  •  I have show hidden files/folders option checked

    Probably you also have the “Hide protected operating system files” option checked.

    • Marked as answer by kobosh3 Wednesday, June 12, 2019 9:21 PM
    Wednesday, June 12, 2019 2:13 PM

All replies

  • Maybe it is a hidden or system directory. See the Attributes property of the DirectoryInfo.

    Saturday, June 8, 2019 5:07 PM
  • thanks Viorel : I have show hidden files/folders option checked
    Saturday, June 8, 2019 6:07 PM
  • Hi kobosh3,

    Thank you for posting here.

    For your question, I test the code, but I could not reproduce the error. Could you provide more details?

    Maybe you do not have the permission, please try to run as admin.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 10, 2019 2:38 AM
    Moderator
  • thanks wendy: i ran visual studio as admin and that did not solve the problem. I also gave every one access to users folder and still same error
    Wednesday, June 12, 2019 11:46 AM
  •  I have show hidden files/folders option checked

    Probably you also have the “Hide protected operating system files” option checked.

    • Marked as answer by kobosh3 Wednesday, June 12, 2019 9:21 PM
    Wednesday, June 12, 2019 2:13 PM
  • thanks Viorel

    I unchecked "Hide protected operating system files" and ran VS as admin but getting same error: access denied

    Wednesday, June 12, 2019 2:43 PM