当前位置: 首页>>代码示例>>C#>>正文


C# ZipFile.GetInputStream方法代码示例

本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.ZipFile.GetInputStream方法的典型用法代码示例。如果您正苦于以下问题:C# ZipFile.GetInputStream方法的具体用法?C# ZipFile.GetInputStream怎么用?C# ZipFile.GetInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.SharpZipLib.Zip.ZipFile的用法示例。


在下文中一共展示了ZipFile.GetInputStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Convert

        public void Convert(EndianBinaryWriter writer)
        {
            var jbtWriter = new JbtWriter(writer);

            var zf = new ZipFile(jarFile);

            foreach (ZipEntry ze in zf)
            {
                if (!ze.IsFile) continue;
                if (!ze.Name.EndsWith(".class")) continue;

                var type = new CompileTypeInfo();

                type.Read(zf.GetInputStream(ze));

                var reader = new BinaryReader(zf.GetInputStream(ze));

                var buffer = new byte[ze.Size];
                reader.Read(buffer, 0, (int)ze.Size);

                jbtWriter.Write(type.Name, buffer);
            }

            jbtWriter.Flush();
        }
开发者ID:will14smith,项目名称:JavaCompiler,代码行数:25,代码来源:JbtConverter.cs

示例2: Search

        public List<Type> Search(string s, List<string> imports)
        {
            if (JbtLocator != null)
            {
                return JbtLocator.Search(s, imports);
            }

            var zf = new ZipFile(JarFile);

            string[] classParts = s.Split('.');
            string classFolder = string.Join("\\", classParts.Take(classParts.Length - 1));
            string className = classParts.Last() + ".class";

            bool isAbsolute = !string.IsNullOrEmpty(classFolder);

            var types = new List<Type>();
            foreach (ZipEntry ze in zf)
            {
                if (!ze.IsFile) continue;

                string fileName = Path.GetFileName(ze.Name);
                string directoryName = Path.GetDirectoryName(ze.Name);

                if (isAbsolute)
                {
                    // absolute
                    if (directoryName == classFolder && fileName == className)
                    {
                        types.Add(ClassLoader.Load(zf.GetInputStream(ze)));
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(directoryName) && fileName == className)
                    {
                        types.Add(ClassLoader.Load(zf.GetInputStream(ze)));
                    }
                    else
                    {
                        foreach (string import in imports)
                        {
                            string[] importParts = import.Split('.');
                            string importFolder = string.Join("\\", importParts.Take(importParts.Length - 1));
                            string importName = importParts.Last();

                            if (!(importName == "*" || importName + ".class" == className)) continue;

                            if (importFolder == directoryName && fileName == className)
                            {
                                types.Add(ClassLoader.Load(zf.GetInputStream(ze)));
                            }
                        }
                    }
                }
            }

            return types;
        }
开发者ID:will14smith,项目名称:JavaCompiler,代码行数:58,代码来源:JarClassLocator.cs

示例3: DocxImporter

        public DocxImporter(string file)
        {
            zip = new ZipFile (file);

            var docEntry = zip.GetEntry (DocumentXmlEntry);
            if (docEntry == null)
                throw new DocxFormatException (string.Format ("Zip entry '{0}' not found", DocumentXmlEntry));

            docXml = XDocument.Load (zip.GetInputStream (docEntry.ZipFileIndex));

            var relsEntry = zip.GetEntry (DocumentRelsEntry);
            if (relsEntry != null)
                relsXml = XDocument.Load (zip.GetInputStream (relsEntry.ZipFileIndex));
        }
开发者ID:joelmartinez,项目名称:DocConverter,代码行数:14,代码来源:DocxImporter.cs

示例4: AreEqual

 /// <summary>
 /// Compares all odt's in outputPath to make sure the content.xml and styles.xml are the same
 /// </summary>
 /// <param name="expectPath">expected output path</param>
 /// <param name="outputPath">output path</param>
 /// <param name="msg">message to display if mismatch</param>
 public static void AreEqual(string expectPath, string outputPath, string msg)
 {
     var outDi = new DirectoryInfo(outputPath);
     var expDi = new DirectoryInfo(expectPath);
     FileInfo[] outFi = outDi.GetFiles("*.od*");
     FileInfo[] expFi = expDi.GetFiles("*.od*");
     Assert.AreEqual(outFi.Length, expFi.Length, string.Format("{0} {1} odt found {2} expected", msg, outFi.Length, expFi.Length));
     foreach (FileInfo fi in outFi)
     {
         var outFl = new ZipFile(fi.FullName);
         var expFl = new ZipFile(Common.PathCombine(expectPath, fi.Name));
         foreach (string name in "content.xml,styles.xml".Split(','))
         {
             string outputEntry = new StreamReader(outFl.GetInputStream(outFl.GetEntry(name).ZipFileIndex)).ReadToEnd();
             string expectEntry = new StreamReader(expFl.GetInputStream(expFl.GetEntry(name).ZipFileIndex)).ReadToEnd();
             XmlDocument outputDocument = new XmlDocument();
             outputDocument.XmlResolver = FileStreamXmlResolver.GetNullResolver();
             outputDocument.LoadXml(outputEntry);
             XmlDocument expectDocument = new XmlDocument();
             expectDocument.XmlResolver = FileStreamXmlResolver.GetNullResolver();
             expectDocument.LoadXml(expectEntry);
             XmlDsigC14NTransform outputCanon = new XmlDsigC14NTransform();
             outputCanon.Resolver = new XmlUrlResolver();
             outputCanon.LoadInput(outputDocument);
             XmlDsigC14NTransform expectCanon = new XmlDsigC14NTransform();
             expectCanon.Resolver = new XmlUrlResolver();
             expectCanon.LoadInput(expectDocument);
             Stream outputStream = (Stream)outputCanon.GetOutput(typeof(Stream));
             Stream expectStream = (Stream)expectCanon.GetOutput(typeof(Stream));
             string errMessage = string.Format("{0}: {1} {2} doesn't match", msg, fi.Name, name);
             Assert.AreEqual(expectStream.Length, outputStream.Length, errMessage);
             FileAssert.AreEqual(expectStream, outputStream, errMessage);
         }
     }
 }
开发者ID:neilmayhew,项目名称:pathway,代码行数:41,代码来源:OdtTest.cs

示例5: InstalledNewVersion

        public static bool InstalledNewVersion()
        {
            var packagedZip = HostingEnvironment.MapPath("~/Packaged.zip");

            if (!File.Exists(packagedZip))
                return false;

            _updating = true;

            var webFolder = HostingEnvironment.MapPath("~");
            var buffer = new byte[4096];

            using (var zipFile = new ZipFile(packagedZip))
                foreach (ZipEntry zipEntry in zipFile)
                {
                    var outFile = Path.Combine(webFolder, zipEntry.Name);
                    Directory.CreateDirectory(Path.GetDirectoryName(outFile));

                    using (var streamWriter = File.Create(outFile))
                        StreamUtils.Copy(zipFile.GetInputStream(zipEntry), streamWriter, buffer);
                }

            var deployedZip = HostingEnvironment.MapPath("~/Deployed.zip");

            if (File.Exists(deployedZip))
                File.Delete(deployedZip);

            File.Move(packagedZip, deployedZip);

            // in case the app hasn't recycled
            HttpRuntime.UnloadAppDomain();

            return true;
        }
开发者ID:FlukeFan,项目名称:LucidDotNet,代码行数:34,代码来源:Upgrader.cs

示例6: ConvertZip

        static void ConvertZip(string filename)
        {
            string basep = Path.GetDirectoryName(filename);
            string plain = Path.GetFileNameWithoutExtension(filename);

            using (HfsFile hfs = HfsFile.Create(basep + @"\" + plain + "_.hfs"))
            using (ZipFile zip = new ZipFile(filename))
            {
                hfs.BeginUpdate();

                if (zip.ZipFileComment == "extra_obscure")
                {
                    // could be better implemented
                    hfs.ObfuscationKey = -1;
                }

                foreach (ZipEntry zipEntry in zip)
                {
                    Console.WriteLine("Processing " + zipEntry.Name);

                    Stream read = zip.GetInputStream(zipEntry);

                    hfs.Add(new StreamLocalSourceHfs(read), zipEntry.Name);
                }

                Console.WriteLine("Compressing..");
                hfs.CommitUpdate();
            }

            Console.WriteLine("Wrote to " + basep + @"\" + plain + "_.hfs");
        }
开发者ID:ZT00000,项目名称:HitTheHipOfSuccubus,代码行数:31,代码来源:Program.cs

示例7: TestLargeZip

        void TestLargeZip(string tempFile, int targetFiles)
        {
            const int BlockSize = 4096;

            byte[] data = new byte[BlockSize];
            byte nextValue = 0;
            for (int i = 0; i < BlockSize; ++i)
            {
                nextValue = ScatterValue(nextValue);
                data[i] = nextValue;
            }

            using (ZipFile zFile = new ZipFile(tempFile))
            {
                Assert.AreEqual(targetFiles, zFile.Count);
                byte[] readData = new byte[BlockSize];
                int readIndex;
                foreach (ZipEntry ze in zFile)
                {
                    Stream s = zFile.GetInputStream(ze);
                    readIndex = 0;
                    while (readIndex < readData.Length)
                    {
                        readIndex += s.Read(readData, readIndex, data.Length - readIndex);
                    }

                    for (int ii = 0; ii < BlockSize; ++ii)
                    {
                        Assert.AreEqual(data[ii], readData[ii]);
                    }
                }
                zFile.Close();
            }
        }
开发者ID:rollingthunder,项目名称:slsharpziplib,代码行数:34,代码来源:GeneralHandling_FileSystem.cs

示例8: UnZipFB2File

        public static void UnZipFB2File(string archiveFileName, string fb2FileId, string outputFolder)
        {
            using (ZipFile zf = new ZipFile(File.OpenRead(archiveFileName)))
            {
                foreach (ZipEntry theEntry in zf)
                {

                    string directoryName = outputFolder;//Path.GetDirectoryName(theEntry.Name);
                    string fileName = directoryName + "\\" + Path.GetFileName(theEntry.Name);

                    // create directory
                    if (directoryName.Length > 0 && !Directory.Exists(directoryName))
                    {
                        Directory.CreateDirectory(directoryName);
                    }

                    if (fileName != String.Empty && Path.GetFileName(fileName).ToLower().Equals(fb2FileId))
                    {
                        byte[] buffer = new byte[4096];
                        Stream zipStream = zf.GetInputStream(theEntry);
                        using (FileStream streamWriter = File.Create(fileName))
                        {
                            StreamUtils.Copy(zipStream, streamWriter, buffer);
                        }
                        break;
                    }
                }
            }
        }
开发者ID:avgx,项目名称:knigoskop,代码行数:29,代码来源:ZipFunctions.cs

示例9: LoadPack

        public static void LoadPack(string packDir)
        {
            Dictionary<string, Dictionary<ushort, string>> allTextMap;
            using (var z = new ZipFile(Path.Combine(packDir, "text.zip")))
            {
                using (var texter = new StreamReader(z.GetInputStream(z.GetEntry("text.csv")), Encoding.UTF8))
                {
                    allTextMap = CSV.ParseCSVText(texter);
                }
            }

            var byterList = new List<BinaryReader>();
            var zipFiles = new List<ZipFile>();
            foreach (var f in Directory.GetFiles(packDir, "*.zip"))
            {
                var name = Path.GetFileNameWithoutExtension(f);
                if (name != null && !name.Equals("text"))
                {
                    var z = new ZipFile(f);
                    zipFiles.Add(z);
                    var byter = new BinaryReader(z.GetInputStream(z.GetEntry(name)));
                    byterList.Add(byter);
                }
            }

            Processor(new Stream(byterList, allTextMap));
            foreach (var z in zipFiles)
            {
                z.Close();
            }
        }
开发者ID:stallboy,项目名称:configgen,代码行数:31,代码来源:CSVLoader.cs

示例10: Load

        public Model Load(string fileName)
        {
            var document = new XmlDocument();

            if (fileName.EndsWith(".tcn"))
            {
                var file = new ZipFile(new FileStream(fileName, FileMode.Open, FileAccess.Read));

                var enumerator = file.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    if (((ZipEntry)enumerator.Current).Name.EndsWith(".xml"))
                    {
                        document.Load(file.GetInputStream((ZipEntry)enumerator.Current));
                        break;
                    }
                }
            }
            else if (fileName.EndsWith(".xml"))
                document.Load(fileName);
            else
                throw new FileLoadException();

            var tcnModel = new TCNFile();
            tcnModel.Parse(document.DocumentElement);

            return tcnModel.Convert();
        }
开发者ID:rmbzlib,项目名称:mcskin3d,代码行数:29,代码来源:ModelFormatTCN.cs

示例11: ExtractResourceZip

 /// <summary>
 /// extract file from zipped resource, and place to temp folder
 /// </summary>
 /// <param name="resource">resource name</param>
 /// <param name="fileName">output name</param>
 /// <param name="OverWriteIfExists">if true,will overwrite the file even if the file exists</param>
 private void ExtractResourceZip(byte[] resource, string fileName, bool OverWriteIfExists = false, int BufferSize = BUFFERSIZE)
 {
     string target = WorkingPath + fileName;
     
     if (OverWriteIfExists || !File.Exists(target))
     {
         ZipFile zip = null;
         FileStream fs = null;
         Stream inStream = null;
         try
         {
             zip = new ZipFile(new MemoryStream(resource));
             inStream = zip.GetInputStream(zip.GetEntry(fileName));
             fs = new FileStream(target, FileMode.Create);
             byte[] buff = new byte[BufferSize];
             int read_count;
             while ((read_count = inStream.Read(buff, 0, BufferSize)) > 0)
             {
                 fs.Write(buff, 0, read_count);
             }
         }
         catch { }
         finally
         {
             if (zip != null) zip.Close();
             if (fs != null) fs.Close();
             if (inStream != null) inStream.Close();
         }
     }
 }
开发者ID:27m10a,项目名称:apkshellext,代码行数:36,代码来源:AndroidToolAgent.cs

示例12: ExtractZipFile

        // EXTRACT ZIP FILE
        private static void ExtractZipFile(string filePath)
        {
            var fileReadStram = File.OpenRead(filePath);
            var zipFile = new ZipFile(fileReadStram);

            // USING ZIP
            using (zipFile)
            {
                foreach (ZipEntry entry in zipFile)
                {
                    if (entry.IsFile)
                    {
                        var entryFileName = entry.Name;
                        var buffer = new byte[4096];
                        var zipStream = zipFile.GetInputStream(entry);

                        var zipToPath = Path.Combine(TempFolderForExtract, entryFileName);
                        var directoryName = Path.GetDirectoryName(zipToPath);

                        if (directoryName != null && directoryName.Length > 0)
                        {
                            Directory.CreateDirectory(directoryName);
                        }

                        using (var streamWriter = File.Create(zipToPath))
                        {
                            StreamUtils.Copy(zipStream, streamWriter, buffer);
                        }
                    }
                }
            }
        }
开发者ID:TeamCapri,项目名称:Initial,代码行数:33,代码来源:ZipToSql.cs

示例13: try_extract_file_names_in_zip

        static bool try_extract_file_names_in_zip(string file_name, string extract_dir, Dictionary<string,string> extract_files) {
            try {
                using (var fs = new FileStream(file_name, FileMode.Open, FileAccess.Read)) {
                    using (var zf = new ZipFile(fs)) {
                        foreach (ZipEntry ze in zf) {
                            if (ze.IsDirectory)
                                continue;

                            if (!extract_files.ContainsKey(ze.Name))
                                continue;

                            string name = extract_dir + "\\" + extract_files[ze.Name];
                            using (Stream s = zf.GetInputStream(ze)) {
                                byte[] buf = new byte[4096];
                                using (FileStream file = File.Create(name)) 
                                  StreamUtils.Copy(s, file, buf);                                
                            }
                        }
                    }
                }
            } catch {
                return false;
            }

            return true;
        }
开发者ID:printedheart,项目名称:logwizard,代码行数:26,代码来源:Program.cs

示例14: ExtractZipFile

        private void ExtractZipFile(string filepath)
        {
            FileStream fileReadStream = File.OpenRead(filepath);
            ZipFile zipFile = new ZipFile(fileReadStream);
            using (zipFile)
            {
                foreach (ZipEntry zipEntry in zipFile)
                {
                    if (zipEntry.IsFile)
                    {
                        String entryFileName = zipEntry.Name;

                        byte[] buffer = new byte[4096];
                        Stream zipStream = zipFile.GetInputStream(zipEntry);

                        string fullZipToPath = Path.Combine(TempFolderForExtract, entryFileName);
                        string directoryName = Path.GetDirectoryName(fullZipToPath);
                        if (directoryName.Length > 0)
                        {
                            Directory.CreateDirectory(directoryName);
                        }

                        using (FileStream streamWriter = File.Create(fullZipToPath))
                        {
                            StreamUtils.Copy(zipStream, streamWriter, buffer);
                        }
                    }
                }
            }
        }
开发者ID:uFreezy,项目名称:Team-Bottle-Green,代码行数:30,代码来源:DataMigrator.cs

示例15: UnZip

        private static bool UnZip(string file)
        {
            var folder = Path.GetDirectoryName(file);
            if (folder == null) return false;
            using (var fs = File.OpenRead(file))
            {
                using (var zf = new ZipFile(fs))
                {
                    foreach (ZipEntry entry in zf)
                    {
                        if (!entry.IsFile) continue; // Handle directories below

                        var outputFile = Path.Combine(folder, entry.Name);
                        var dir = Path.GetDirectoryName(outputFile);
                        if (dir == null) continue;
                        if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);

                        using (var stream = zf.GetInputStream(entry))
                        {
                            using (var sw = File.Create(outputFile))
                            {
                                stream.CopyTo(sw);
                            }
                        }

                    }
                }
            }
            return true;
        }
开发者ID:jpiolho,项目名称:sledge,代码行数:30,代码来源:UpdaterForm.cs


注:本文中的ICSharpCode.SharpZipLib.Zip.ZipFile.GetInputStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。