Beispiel #1
0
 /// <summary>
 /// Populate the allTagsList when the class is loaded
 /// </summary>
 static TagReader()
 {
     TagReader.refreshTags();
 }
Beispiel #2
0
        /// <summary>
        /// Traverses a Directory recursive and uses a TagReader List as a Wrapper for alle the used tags
        /// </summary>
        /// <param name="directory"></param>
        /// <returns></returns>
        public static List <TagReader> getAllTagReadersFromDirectory(DirectoryInfo directory, WindowsTagAnalyzer.com.fh.praktikanten.gui.WindowsTagAnalyzerGUI gui)
        {
            gui.SetProgressTagReader("Scanning... " + directory.FullName);

            System.IO.FileInfo[]      allFiles       = null;
            System.IO.DirectoryInfo[] subDirectories = null;

            Folder shellFolder = null;

            //List to store all tag readers
            List <TagReader> tagReaders = new List <TagReader>();

            try
            {
                //get all Files from the current directory
                allFiles = directory.GetFiles();
            }

            catch (UnauthorizedAccessException e)
            {
                //Oops, you should have more rights
                //MessageBox.Show("You have no Access to the directory: \"" + directory.FullName + "\"!");
            }
            catch (System.IO.DirectoryNotFoundException e)
            {
                //When this happens, something, somewhere, totally went wrong
                MessageBox.Show("The directory: \"" + directory.FullName + "\" could not be found!");
            }

            //There are more Files to proceed
            if (allFiles != null)
            {
                //Save TagReaders
                foreach (System.IO.FileInfo fi in allFiles)
                {
                    try
                    {
                        //Create ShellFolder
                        shellFolder = sh.NameSpace(fi.DirectoryName);
                    }
                    catch (Exception e)
                    {
                        //MessageBox.Show(e.ToString());
                    }
                    //Happens sometimes to folders like
                    //C:\$Recycle.Bin\S-1-5-21-1712340149-1785855708-1618849827-1001\$RV05Q8E\sqliteLib\
                    //Windows Explorer is also unable to open them
                    if (shellFolder != null)
                    {
                        TagReader tr = new TagReader(shellFolder, fi.FullName);

                        //Add a new TagReader to the list
                        //Do this synchronized because then the gui dont have to wait for the end of this function
                        TagReader.allTagReaders.Add(new TagReader(shellFolder, fi.FullName));
                    }
                }

                // Now find all the subdirectories under this directory.
                subDirectories = directory.GetDirectories();

                foreach (System.IO.DirectoryInfo dirInfo in subDirectories)
                {
                    // Resursive call for each subdirectory.
                    getAllTagReadersFromDirectory(dirInfo, gui);
                }
            }

            return(TagReader.allTagReaders);
        }