none
Determination File Ownership, For Some Files We Unaccountably Get An Exception RRS feed

  • Question

  • I've summarized the various error messages that are presented in the below shown exception handler. Can you explain why the system takes exception to my requests (only on some files) and what the various error messages are trying to tell me? What changes can I make to my program, or to the environment it runs in, to guarantee the exceptions will not occur?  By the way, I've put every conceivable privilege into effect including running the program as Administrator.  Windows 8.1.

    For each filename pulled out of the NTFS directory:

                                try
                                {
                                    System.Security.AccessControl.FileSecurity fileSecurity = System.IO.File.GetAccessControl(fullFileName);
                                    System.Security.Principal.IdentityReference identityReference = fileSecurity.GetOwner(typeof(System.Security.Principal.SecurityIdentifier));
                                    System.Security.Principal.NTAccount ntAccount = identityReference.Translate(typeof(System.Security.Principal.NTAccount)) as System.Security.Principal.NTAccount;
                                    ownerName = ntAccount.Value;
                                }
                                catch (Exception e)
                                {
                                    ownerName = "Could not be determined.";
                                    bool bAlreadyThere = false;
                                    foreach (string s in reasonsFailure)
                                        if (s.Equals(e.Message))
                                            bAlreadyThere = true;
                                    if (!bAlreadyThere)
                                        reasonsFailure.Add(e.Message);
                                }

                               

    A small sample of tabular output:

    A         C:\END                                                                BUILTIN\Administrators
    AHYS      C:\hiberfil.sys                                                       Could not be determined.
    HR        C:\mfg.sdr                                                            NT AUTHORITY\SYSTEM
    A         C:\News Themes.wav                                                    BUILTIN\Administrators
    AHS       C:\pagefile.sys                                                       Could not be determined.
    A         C:\{17D951F2-F20F-4D49-993B-A8610C14FCDB}                             BUILTIN\Administrators
    A         C:\{3C7C6689-D549-4289-8112-F2617368D0E1}                             BUILTIN\Administrators
    A         C:\{3EAC9E76-A4D6-4880-85AE-69DB24D8952C}                             BUILTIN\Administrators
    A         C:\{58692F65-89ED-455C-8D34-2A2FCFC8CF6C}                             BUILTIN\Administrators
    A         C:\{619D9CE2-368E-4867-8CA6-87279D7D25E8}                             BUILTIN\Administrators
    A         C:\{734CEDF9-F238-4E68-8CFE-EDA6D2771A15}                             BUILTIN\Administrators
    A         C:\{936BF31A-5B8D-4756-A706-3727F2344167}                             BUILTIN\Administrators
    A         C:\{9E1A2883-0746-41AD-80FD-37097E371961}                             BUILTIN\Administrators
    A         C:\{D65F6B69-9D9E-417C-9470-8882587D29F7}                             BUILTIN\Administrators
    A         C:\{F8799D84-B3AD-41B4-8B61-3542E16186F9}                             BUILTIN\Administrators
    A         C:\$$$A\CreateKeepSourceLogEvent.exe                                  BUILTIN\Administrators
    A         C:\$$$A\CreateKeepSourceLogEvent.pdb                                  BUILTIN\Administrators

    Tail Sheet:

    A - archive
    C - compressed
    V - device
    D - directory
    E - encrypted
    H - hidden
    I - integrity stream
    N - normal
    Z - no scrub data
    Y - not content indexed
    O - offline
    R - readonly
    P - reparse point
    W - sparse file
    S - system file
    T - temporary file

    Method failed with unexpected error code 32.
    Some or all identity references could not be translated.
    Attempted to perform an unauthorized operation.


    MARK D ROCKMAN

    Thursday, December 4, 2014 2:12 PM

All replies

  • Hello MARK,

    According to your provided small sample of tabular output, I assume that the third column is the caused reason, from my understanding, these files should be accessed by BUILTIN\Administrators account only, and as far as I know, this account is disable by default. After searching for a while, there is an article discussing about how to enable this account which applies To: Windows 8, Windows 8.1, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2:

    Enable and Disable the Built-in Administrator Account

    You could follow it to see after you enable it, if you could get the ownname.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 5, 2014 2:10 AM
    Moderator
  • My app produces a report in three columns. Column Number One is a string of letters. Each letter represents a FileAttribute in accordance with the Tail Sheet. Column Two is the name of the file. Column Three is the file's owner. My app does not access any of the files. It enumerates the files using standard methods provided by the .Net Framework. That is, unless by access, you mean obtain the FileAttributes and Owner. Then, yes it does access the files. My app does not run under the BUILTIN\Administrators account.  Some of the files clearly show the owner of the files is BUILTIN\Administrators.  Clearly one does not have to enable that account to see that the owner of, for example, the file C:\{F8799D84-B3AD-41B4-8B61-3542E16186F9} is BUILTIN\Administrators.   An account does not even have to exist for a file to be owned by such an account.  I have a machine whose Guest account is disabled.  Yet there are many files owned by the Guest account.

    Following your reasoning, I should not see any files whose owner is BUILTIN\Administrators.  Yet there are several files whose owner is shown to be that account, despite that account being disabled.

    You assert the caused reason for some of the reported files to refuse to reveal their owners is the Third Column.  At least, I think that's what you mean.  Can you clarify?


    MARK D ROCKMAN

    Friday, December 5, 2014 5:20 AM
  • Hello MARK,

    Thanks for your clarification for this issue.

    >> You assert the caused reason for some of the reported files to refuse to reveal their owners is the Third Column.  At least, I think that's what you mean.  Can you clarify?

    Yes, that is what I mean while now I know they aren’t and I just ignore the exact error message below it. It is my mistake.

    For the error message “Method failed with unexpected error code 32.”, it should be a system error and all system error are shown in below link:

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx

    It shows the process cannot access the file because it is being used by another process. According to your provided code, I reproduce it with files have .sys extension and as far as I know, files have a .sys extension are Windows System Files and used by the Microsoft DOS and Windows operating systems to store data about the device drivers, settings and other Windows system information on a computer. It is not recommended to access these file in program.

    For the other two exceptions ”Some or all identity references could not be translated” and ”Attempted to perform an unauthorized operation”, unfortunately, I do not reproduce them, my suggestion is that in code to process the exception, you could also add the file name which causes the exception, this would help narrow down this issue.

    Hope this is helpful to you.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 5, 2014 6:06 AM
    Moderator
  • Thanks for your quick reply.  The tabular output of the program shows "Could not be determined." adjacent to the filename of the file that causes the exception. That means we already know which files are causing exceptions.   I don't think you have a good handle on the nature of this problem.  We are dealing in metadata here.  Metadata is data concerning data.  Good design principles would allow an application to ask any file (ANY FILE) what its attributes are and who its owner is.  The data in the file isn't accessed.  So the file isn't accessed.  Windows may be running my code through its Discretionary Access Control List mechanism as if file data were being accessed.  And this would be a design flaw in Windows.   We cannot know what Windows is doing because that is proprietary information on a need-to-know basis. I can send you the app and you can reproduce these phenomena at your leisure.  In fact, here is all the source code. 

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.IO;
    using System.Security.AccessControl;
    using System.Security.Principal;
    
    namespace OWNALL  // this app prints the names of all accessible files on the named drive letter together with their individual owner names and System.IO.FileAttributes
                      // this app optionally changes ownership of all accessible files to that of the logged-in end user and minimizes extraneous System.IO.FileAttributes
                      // it is possible to specify a root directory instead of a drive letter
    {
        class Program
        {
            static void Main(string[] args)
            {
                List<string> reasonsFailure = new List<string>();
                try
                {
                    Console.WriteLine("Enter \"ownall . .\" to see the Help text.");
                    try
                    {
                        GHP(1);  // this has to be the 64-bit version of the DLL for some unknown reason -- probably won't work when running 32-bit Windows -- obviously ivory tower guys have zero practical experience
                    }
                    catch
                    {
                        Console.WriteLine("Goto High Priority is impossible in this environment -- we shall muddle through.");
                    }
                    bool bToBeMoved = false;  // we want to plant file contents in a newly created file so that the file assumes new ownership; this avoids touching the Microsoft DACL APIs which require immortals for understanding not to mention the need to code in C++
                    string tempdir = Environment.GetEnvironmentVariable("TEMP");
                    string tempfile = tempdir + @"\" + "kM6b4RY59FtV7ew.AAA";
                    string root = "";
                    string fn = "";
                    if (System.IO.Directory.Exists(tempdir))
                    { }
                    else
                    {
                        System.IO.Directory.CreateDirectory(tempdir);
                    }
                    if (System.IO.Directory.Exists(tempdir))
                    { }
                    else
                    {
                        Console.WriteLine("An error occurred.");
                        return;
                    }
                    if (args.Length == 2)
                    {
                        if (args[0].Equals("+"))
                        {
                            bToBeMoved = false;
                        }
                        else if (args[0].Equals("-"))
                        {
                            bToBeMoved = true;
                            Console.WriteLine("You have requested file Ownership changes to be made.");
                        }
                        else
                        {
                            Console.WriteLine("A command line with 2 args may  contain + as the first arg.");
                            Console.WriteLine("A command line with 2 args may  contain - as the first arg.");
                            Console.WriteLine("+ means do not make any Ownership changes, but do generate a report.");
                            Console.WriteLine("- means the same as + but request also to make Ownership changes.");
                            Console.WriteLine("When you request Ownership changes,");
                            Console.WriteLine("you must run this app a 2nd time to see the changes in the report.");
                            return;
                        }
                        root = args[1];
                        if (System.IO.Directory.Exists(root))
                        { }
                        else
                        {
                            Console.WriteLine("There is no such directory or folder named as follows:");
                            Console.WriteLine(root);
                            return;
                        }
                        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(root);
                        root = di.FullName;
                        Console.WriteLine("This report pertains to:  " + root);
                    }
                    else if (args.Length == 1)
                    {
                        string driveLetter = args[0].ToUpper();
                        if (driveLetter.Length != 1)
                        {
                            Console.WriteLine("'" + driveLetter + "' is an invalid drive letter.");
                            return;
                        }
                        char T = driveLetter[0];
                        if (T >= 'A' && T <= 'Z')
                        {
                            root = driveLetter + @":\";
                        }
                        else
                        {
                            Console.WriteLine("'" + driveLetter + "' is an invalid drive letter.");
                            return;
                        }
                    }
                    else
                    {
                        Console.WriteLine("You need to name a drive letter on the command line.");
                        return;
                    }
                    if (args.Length == 1 || args.Length == 2)
                    {
    
                        LeafNodes ln = new LeafNodes(root);
                        string swfile = tempdir + @"\OwnershipReport.txt";
                        Console.WriteLine("Find your report here:  " + swfile);
                        using (System.IO.StreamWriter sw = new System.IO.StreamWriter(swfile))
                        {
                            for (; ; )
                            {
                                fn = ln.GetFilename();
                                if (fn.Length == 0)  // i.e. when we've seen the last filename returned by LeafNodes
                                {
                                    sw.WriteLine("");
                                    sw.WriteLine("A - archive");
                                    sw.WriteLine("C - compressed");
                                    sw.WriteLine("V - device");
                                    sw.WriteLine("D - directory");
                                    sw.WriteLine("E - encrypted");
                                    sw.WriteLine("H - hidden");
                                    sw.WriteLine("I - integrity stream");
                                    sw.WriteLine("N - normal");
                                    sw.WriteLine("Z - no scrub data");
                                    sw.WriteLine("Y - not content indexed");
                                    sw.WriteLine("O - offline");
                                    sw.WriteLine("R - readonly");
                                    sw.WriteLine("P - reparse point");
                                    sw.WriteLine("W - sparse file");
                                    sw.WriteLine("S - system file");
                                    sw.WriteLine("T - temporary file");
                                    sw.WriteLine("");
                                    foreach (string s in reasonsFailure)
                                        sw.WriteLine(s);
                                    goto Edinburgh;
                                }
                                string fullFileName = "";
                                if (System.IO.File.Exists(fn))
                                {
                                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(fn);
                                    fullFileName = fileInfo.FullName;
                                }
                                else
                                {
                                    goto Hell;
                                }
                                /*
            Archive The file is a candidate for backup or removal.  
            Compressed The file is compressed. 
            Device Reserved for future use. 
            Directory The file is a directory. 
            Encrypted The file or directory is encrypted. For a file, this means that all data in the file is encrypted. For a directory, this means that encryption is the default for newly created files and directories. 
            Hidden The file is hidden, and thus is not included in an ordinary directory listing. 
             IntegrityStream The file or directory includes data integrity support. When this value is applied to a file, all data streams in the file have integrity support. When this value is applied to a directory, all new files and subdirectories within that directory, by default, include integrity support. 
            Normal The file is a standard file that has no special attributes. This attribute is valid only if it is used alone. 
             NoScrubData The file or directory is excluded from the data integrity scan. When this value is applied to a directory, by default, all new files and subdirectories within that directory are excluded from data integrity. 
            NotContentIndexed The file will not be indexed by the operating system's content indexing service. 
            Offline The file is offline. The data of the file is not immediately available. 
            ReadOnly The file is read-only. 
            ReparsePoint The file contains a reparse point, which is a block of user-defined data associated with a file or a directory. 
            SparseFile The file is a sparse file. Sparse files are typically large files whose data consists of mostly zeros. 
            System The file is a system file. That is, the file is part of the operating system or is used exclusively by the operating system. 
            Temporary The file is temporary. A temporary file contains data that is needed while an application is executing but is not needed after the application is finished. File systems try to keep all the data in memory for quicker access rather than flushing the data back to mass storage. A temporary file should be deleted by the application as soon as it is no longer needed. 
                                */
                                string attributesString = "";
                                System.IO.FileAttributes fileAttributes = System.IO.File.GetAttributes(fullFileName);
                                if ((fileAttributes & System.IO.FileAttributes.Archive) == System.IO.FileAttributes.Archive)
                                    attributesString = attributesString + "A";
                                if ((fileAttributes & System.IO.FileAttributes.Compressed) == System.IO.FileAttributes.Compressed)
                                    attributesString = attributesString + "C";
                                if ((fileAttributes & System.IO.FileAttributes.Device) == System.IO.FileAttributes.Device)
                                    attributesString = attributesString + "V";
                                if ((fileAttributes & System.IO.FileAttributes.Directory) == System.IO.FileAttributes.Directory)
                                    attributesString = attributesString + "D";
                                if ((fileAttributes & System.IO.FileAttributes.Encrypted) == System.IO.FileAttributes.Encrypted)
                                    attributesString = attributesString + "E";
                                if ((fileAttributes & System.IO.FileAttributes.Hidden) == System.IO.FileAttributes.Hidden)
                                    attributesString = attributesString + "H";
                                /*
                                if ((fileAttributes & System.IO.FileAttributes.IntegrityStream) == System.IO.FileAttributes.IntegrityStream)
                                    attributesString = attributesString + "I";
                                */
                                if ((fileAttributes & System.IO.FileAttributes.Normal) == System.IO.FileAttributes.Normal)
                                    attributesString = attributesString + "N";
                                /*
                                if ((fileAttributes & System.IO.FileAttributes.NoScrubData) == System.IO.FileAttributes.NoScrubData)
                                    attributesString = attributesString + "Z";
                                */
                                if ((fileAttributes & System.IO.FileAttributes.NotContentIndexed) == System.IO.FileAttributes.NotContentIndexed)
                                    attributesString = attributesString + "Y";
                                if ((fileAttributes & System.IO.FileAttributes.Offline) == System.IO.FileAttributes.Offline)
                                    attributesString = attributesString + "O";
                                if ((fileAttributes & System.IO.FileAttributes.ReadOnly) == System.IO.FileAttributes.ReadOnly)
                                    attributesString = attributesString + "R";
                                if ((fileAttributes & System.IO.FileAttributes.ReparsePoint) == System.IO.FileAttributes.ReparsePoint)
                                    attributesString = attributesString + "P";
                                if ((fileAttributes & System.IO.FileAttributes.SparseFile) == System.IO.FileAttributes.SparseFile)
                                    attributesString = attributesString + "W";
                                if ((fileAttributes & System.IO.FileAttributes.System) == System.IO.FileAttributes.System)
                                    attributesString = attributesString + "S";
                                if ((fileAttributes & System.IO.FileAttributes.Temporary) == System.IO.FileAttributes.Temporary)
                                    attributesString = attributesString + "T";
    
                                string ownerName = "Could not be determined.";
                                try
                                {
                                    System.Security.AccessControl.FileSecurity fileSecurity = System.IO.File.GetAccessControl(fullFileName);
                                    System.Security.Principal.IdentityReference identityReference = fileSecurity.GetOwner(typeof(System.Security.Principal.SecurityIdentifier));
                                    System.Security.Principal.NTAccount ntAccount = identityReference.Translate(typeof(System.Security.Principal.NTAccount)) as System.Security.Principal.NTAccount;
                                    ownerName = ntAccount.Value;
                                }
                                catch (Exception e)
                                {
                                    ownerName = "Could not be determined.";
                                    bool bAlreadyThere = false;
                                    foreach (string s in reasonsFailure)
                                        if (s.Equals(e.Message))
                                            bAlreadyThere = true;
                                    if (!bAlreadyThere)
                                        reasonsFailure.Add(e.Message);
                                }
                                char[] tumble = new char[132];
                                int i;
                                for (i = 0; i < 132; i++)
                                    tumble[i] = ' ';
                                i = 0;
                                foreach (char c in attributesString)
                                {
                                    tumble[i++] = c;
                                    if (i == 10)
                                        break;
                                }
                                i = 10;
                                foreach (char c in fullFileName)
                                {
                                    tumble[i++] = c;
                                    if (i == 80)
                                        break;
                                }
                                i = 80;
                                foreach (char c in ownerName)
                                {
                                    tumble[i++] = c;
                                    if (i == 132)
                                        break;
                                }
                                string editedString = "";
                                foreach (char c in tumble)
                                    editedString = editedString + c.ToString();
                                char[] trimChars = { ' ' };
                                editedString = editedString.TrimEnd(trimChars);
                                sw.WriteLine(editedString);
                                if (bToBeMoved)
                                {
                                    /*
                                                                1.  Ensure the file that is going to get a new owner actually exists.  If not, do nothing.  (The file mentioned in this item is called the payload file.)
                                                                2.  Ensure the %TEMP% directory exists.  It should because this app creates it at the start when it doesn't exist.
                                                                3.  If this program's scratch file exists in the %TEMP% directory then get rid of it.
                                                                4.  Copy the payload file to the scratch file.
                                                                5.  Delete the payload file.  There goes the old ownership attachment to the data.
                                                                6.  Copy the scratch file to a new copy of the payload file.  This file should be owned by the logged-in end user.
                                                                7.  Get rid of the scratch file.
                                    */
                                    try
                                    {
                                        if (System.IO.File.Exists(fullFileName))
                                        {
                                            if (System.IO.Directory.Exists(tempdir))
                                            {
                                                if (System.IO.File.Exists(tempfile))
                                                {
                                                    System.IO.File.Delete(tempfile);
                                                }
                                                System.IO.File.Copy(fullFileName, tempfile);
                                                System.IO.File.Delete(fullFileName);
                                                System.IO.File.Copy(tempfile, fullFileName);  // this creates the file anew with, presumably, Ownership credentials matching those of the logged-in end user
                                                System.IO.File.Delete(tempfile);
                                            }
                                        }
                                    }
                                    catch
                                    {
                                        Console.WriteLine("Contingency occurred while trying to change Ownership of");
                                        Console.WriteLine("      " + fullFileName);
                                    }
                                }
                            Hell: continue;
                            }
                        Edinburgh: Console.WriteLine("END OF PROGRAM.");
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine("END OF PROGRAM.  With an error.");
                    return;
                }
            }
            [System.Runtime.InteropServices.DllImport(@".\GHP.dll")]
            static extern int GHP(int togglePosition);
        }
    }
    

    and

    using System;
    using System.Collections.Generic;
    using System.Text;
    
    /*  April 6, 2008
     * 
    William McIlroy wrote:
    > I have written a backup utility for my OWN USE that pleases me, unlike any 
    > other backup utility.  In the course of using it, I find, in Vista, what 
    > appear to be places in a file system's tree where the same files are 
    > duplicated.  In other words, a given subtree appears in more than one place 
    > in the larger tree.  Can someone in the know confirm this and tell me how to 
    > avoid backing up the same files more than one time per backup program run?  
    > Many thanks.
    
    They use junctions in Vista, to make trees appear more than once.
    
    ==> On each check of going down one branch chec, if it is
    a junction reparse point, and then only save the junction
    itself, but not the whole tree once more
    
    Ciao Hermann
     * 
    */
    namespace OWNALL
    {
        public class LeafNodes
        {
            private System.IO.DirectoryInfo di;
            private System.IO.DirectoryInfo[] directoryList;
            private System.IO.FileInfo[] filesList;
            private System.Collections.ArrayList fullFilenames = new System.Collections.ArrayList();
            private System.Collections.ArrayList directoryNames = new System.Collections.ArrayList();
            private static int nestingLevel = 0;
            private static System.IO.StreamWriter trace = null;
            public LeafNodes(string rootDirectory)
            {
                try
                {
                    di = new System.IO.DirectoryInfo(rootDirectory);
                    try
                    {
                        directoryList = di.GetDirectories();
                    }
                    catch
                    {
                        directoryList = null;
                        // RegisterException.WriteLogEntry("The following directory was denied access on GetDirectories():  " + di.FullName, System.Drawing.Color.Red);
                        // RegisterException.WriteLogEntry(e1.Message, System.Drawing.Color.Red);
                    }
                    try
                    {
                        filesList = di.GetFiles();
                    }
                    catch
                    {
                        filesList = null;
                        // RegisterException.WriteLogEntry("The following directory was denied access on GetFiles():  " + di.FullName, System.Drawing.Color.Red);
                        // RegisterException.WriteLogEntry(e2.Message, System.Drawing.Color.Red);
                    }
                    /*
               // Recurse into subdirectories of this directory.
    
                    string[] subdirEntries = Directory.GetDirectories(sourceDir);
    
                    foreach (string subdir in subdirEntries)
    
                        // Do not iterate through reparse points
    
                        if ((File.GetAttributes(subdir) &
    
                             FileAttributes.ReparsePoint) !=
    
                                 FileAttributes.ReparsePoint)
    
                            ProcessDir(subdir, recursionLvl + 1);
               
                     */
                    if (directoryList != null)
                        foreach (System.IO.DirectoryInfo w in directoryList)
                        {
                            if ((System.IO.File.GetAttributes(w.FullName) &
                                 System.IO.FileAttributes.ReparsePoint) !=
                                 System.IO.FileAttributes.ReparsePoint)
                                directoryNames.Add(w.FullName);
                            /*
                            else
                            {
                                System.Windows.Forms.MessageBox.Show("The directory (" + w.FullName + ") is a Reparse Point and will not be saved more than once.");
                            }
                            */
                        }
                    if (filesList != null)
                        foreach (System.IO.FileInfo v in filesList)
                            fullFilenames.Add(v.FullName);
                    return;
                }
                catch (Exception leafException)
                {// case of a too long directory name and/or too long filename
                    string s = leafException.Message;
                    return;
                }
            }
            public string GetFilename()
            {
                {
                    if (trace != null)
                        trace.WriteLine("BEGIN GetFilename() at nesting level " + nestingLevel.ToString());
                    nestingLevel++;
                    if (trace != null)
                        trace.WriteLine("   fullFilenames.Count = " + fullFilenames.Count.ToString());
                    if (fullFilenames.Count > 0)
                    {
                        string filename = (string)fullFilenames[0];
                        fullFilenames.Remove(fullFilenames[0]);
                        if (trace != null)
                            trace.WriteLine("   RETURN filename 1 = " + filename.ToUpper());
                        nestingLevel--;
                        //// RegisterException.WriteLogEntry(filename);
                        return filename;
                    }
                    if (trace != null)
                        trace.WriteLine("   directoryNames.Count = " + directoryNames.Count.ToString());
                    while (directoryNames.Count > 0)
                    {
                        string directoryname = (string)directoryNames[0];
                        directoryNames.Remove(directoryNames[0]);
                        LeafNodes leafnodes = new LeafNodes(directoryname);
                        for (; ; )
                        {
                            string f = leafnodes.GetFilename();
                            if (f.Length > 0)
                                fullFilenames.Add(f);
                            else
                                break;
                        }
                        if (fullFilenames.Count > 0)
                            break;
                    }
                    if (fullFilenames.Count > 0)
                    {
                        string filename = (string)fullFilenames[0];
                        fullFilenames.Remove(fullFilenames[0]);
                        if (trace != null)
                            trace.WriteLine("   RETURN filename 2 = " + filename);
                        nestingLevel--;
                        //// RegisterException.WriteLogEntry(filename);
                        return filename;
                    }
                    if (trace != null)
                        trace.WriteLine("   RETURN filename 3 = null ");
                    nestingLevel--;
                    //// RegisterException.WriteLogEntry("--- END OF DIRECTORY ---");
                    return "";  // it may be a wild assumption, but assume Windows never returns a filename of zero length
                }
            }
        }
    }
    
    


    MARK D ROCKMAN

    Friday, December 5, 2014 6:31 AM
  • Hello,

    Thanks for sharing the resource code. With your code, I only reproduce the system error 32 exception caused by the .sys file, and not sure if it is due to environment, my opinion for this system error 32 is to avoid access these files have .sys extension. For the two other ones, I am trying to involve someone experienced to help look into this thread, it may take some time and as soon as we get any result, we will post back.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 5, 2014 7:46 AM
    Moderator
  • Mark,

    Error Code 32 indicates a sharing violationThe process cannot access the file because it is being used by another process.

    Evidently you need exclusive access to a file to obtain these file/security attributes


    Thursday, August 20, 2015 12:59 AM