Easy unzipping of ZIP files.
Silverlight has built-in capabilities to extract files from a zip file. However, you need to know up front what files are in the zip to unzip them. This utility parses the headers and gives you access to the file names embedded in the zip. Furthermore, Silverlight unzipping has some limitations and doesn't support zip files where the file sizes and CRC is placed after the file data. This utility detects this case and re-arranges the bytes so Silverlight can read and uncompress the files.
Inheritance: IDisposable
 public CompendiumArchiveProcessor(FileInfo compendiumFile, Proxy.IMapManager mapManager, Proxy.INode map)
 {
     CompendiumFile = compendiumFile;
     _zipFile = new ZipFile(CompendiumFileStream);
     _fileCount = _zipFile.FileNamesInZip.Count();
     _fileNames = _zipFile.FileNamesInZip.ToList();
     MapManager = mapManager;
     Map = map;
 }
Ejemplo n.º 2
0
        public IFileProcessor CreateFileProcessor(FileInfo file, Proxy.IMapManager mapManager, Proxy.INode map, Point location)
        {
            if (file.Name.EndsWith(".zip"))
            {
                using (FileStream fileStream = file.OpenRead())
                {
                    bool isCompendiumExport = false;
                    bool hasExportsFolderAndXml = false;
                    bool hasLinkedFilesFolder = false;

                    ZipFile zipFile = new ZipFile(fileStream);

                    foreach (string filename in zipFile.FileNamesInZip)
                    {
                        if (filename.StartsWith("Exports/"))
                        {
                            if (filename.EndsWith(".xml"))
                            {
                                isCompendiumExport = true;
                                //hasExportsFolderAndXml = true;

                                break;
                            }
                        }

                        //if (filename.StartsWith("Linked Files/"))
                        //{
                        //    hasLinkedFilesFolder = true;
                        //}

                        //if (hasExportsFolderAndXml && hasLinkedFilesFolder)
                        //{
                        //    isCompendiumExport = true;

                        //    break;
                        //}
                    }

                    if (isCompendiumExport)
                    {
                        var compendiumFileProcessor = new CompendiumArchiveProcessor(file,
                            mapManager, map);

                        return compendiumFileProcessor;
                    }
                }
            }
            else if (file.Name.EndsWith(".xml"))
            {
                using (var stream = file.OpenRead())
                {
                    var compendiumXmlProcessor = new CompendiumXmlFileProcessor(stream, "", "");
                    compendiumXmlProcessor.MapManager = mapManager;
                    compendiumXmlProcessor.Map = map;
                    if (compendiumXmlProcessor.Nodes.Any())
                    {
                        return compendiumXmlProcessor;
                    }
                    
                }
            }

            return new DroppedFileProcessor(file, location);
        }