Beispiel #1
0
        public static HashSet <CompDBXmlClass.CompDB> GetCompDBsFromUUPFiles(string UUPPath)
        {
            HashSet <CompDBXmlClass.CompDB> compDBs = new HashSet <CompDBXmlClass.CompDB>();

            try
            {
                if (Directory.EnumerateFiles(UUPPath, "*aggregatedmetadata*").Count() > 0)
                {
                    using (CabinetHandler cabinet = new CabinetHandler(File.OpenRead(Directory.EnumerateFiles(UUPPath, "*aggregatedmetadata*").First())))
                    {
                        foreach (var file in cabinet.Files.Where(x => x.EndsWith(".xml.cab", StringComparison.InvariantCultureIgnoreCase)))
                        {
                            try
                            {
                                using (CabinetHandler cabinet2 = new CabinetHandler(cabinet.OpenFile(file)))
                                {
                                    string xmlfile = cabinet2.Files.First();
                                    using (Stream xmlstream = cabinet2.OpenFile(xmlfile))
                                    {
                                        compDBs.Add(CompDBXmlClass.DeserializeCompDB(xmlstream));
                                    }
                                }
                            }
                            catch { }
                        }
                    }
                }
                else
                {
                    IEnumerable <string> files = Directory.EnumerateFiles(UUPPath).Select(x => Path.GetFileName(x)).Where(x => x.EndsWith(".xml.cab", StringComparison.InvariantCultureIgnoreCase));

                    foreach (var file in files)
                    {
                        try
                        {
                            using (CabinetHandler cabinet2 = new CabinetHandler(File.OpenRead(Path.Combine(UUPPath, file))))
                            {
                                string xmlfile = cabinet2.Files.First();
                                using (Stream xmlstream = cabinet2.OpenFile(xmlfile))
                                {
                                    compDBs.Add(CompDBXmlClass.DeserializeCompDB(xmlstream));
                                }
                            }
                        }
                        catch { }
                    }
                }
            }
            catch { }

            return(compDBs);
        }