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


C# ZipInputStream.GetNextEntry方法代码示例

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


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

示例1: InstallApplication

        public static void InstallApplication(string zipFileName, byte[] zipFileContent)
        {
            string folderName = zipFileName.Replace(".zip", "").Replace(".ZIP", "");
            string binFolder = HttpContext.Current.Server.MapPath("~/bin");
            if (Directory.Exists(binFolder + "/" + folderName))
                Directory.SetCreationTime(binFolder + "/" + folderName, DateTime.Now);
            Directory.CreateDirectory(binFolder + "/" + folderName);
            using (MemoryStream memStream = new MemoryStream(zipFileContent))
            {
                memStream.Position = 0;
                using (ZipInputStream zipInput = new ZipInputStream(memStream))
                {
                    ZipEntry current = zipInput.GetNextEntry();
                    while (current != null)
                    {
                        using (FileStream output = new FileStream(
                            binFolder + "/" + folderName + "/" + current.Name,
                            FileMode.Create,
                            FileAccess.Write))
                        {
                            byte[] buffer = new byte[current.Size];
                            zipInput.Read(buffer, 0, buffer.Length);
                            output.Write(buffer, 0, buffer.Length);
                        }
                        current = zipInput.GetNextEntry();
                    }
                }
            }
            Language.Instance.SetDefaultValue("ApplicationWasInstalledRedirecting", @"
A new application was installed, and hence we had to refresh the browser 
and you might need to login again...");
            AjaxManager.Instance.Redirect("~/?message=ApplicationWasInstalledRedirecting");
        }
开发者ID:greaterwinner,项目名称:ra-brix,代码行数:33,代码来源:AppInstaller.cs

示例2: TestCompressSingleMessagePart

        public void TestCompressSingleMessagePart()
        {
            var pipeline = PipelineFactory.CreateEmptySendPipeline();

            var component = new CompressMessage {DefaultZipEntryFileExtension = "xml"};

            var msg = MessageHelper.CreateFromString("<testmessage1></testmessage1>");

            pipeline.AddComponent(component, PipelineStage.Encode);

            var result = pipeline.Execute(msg);

            ZipInputStream zipInputStream = new ZipInputStream(result.BodyPart.GetOriginalDataStream());
            ZipEntry zipEntry = zipInputStream.GetNextEntry();
            int i = 0;
            while (zipEntry != null)
            {
                Guid g;
                Assert.IsTrue(Guid.TryParse(Path.GetFileNameWithoutExtension(zipEntry.Name), out g));
                Assert.AreEqual(".xml", Path.GetExtension(zipEntry.Name));
                zipEntry = zipInputStream.GetNextEntry();
                i++;
            }

            Assert.AreEqual(1,i);
        }
开发者ID:robinhultman,项目名称:CompressMessage,代码行数:26,代码来源:CompressMessageTests.cs

示例3: UnZip

        public static void UnZip(this FileInfo fileInfo, string destiantionFolder)
        {
            using (var fileStreamIn = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read))
            {
                using (var zipInStream = new ZipInputStream(fileStreamIn))
                {
                    var entry = zipInStream.GetNextEntry();
                    FileStream fileStreamOut = null;
                    while (entry != null)
                    {
                        fileStreamOut = new FileStream(destiantionFolder + @"\" + entry.Name, FileMode.Create, FileAccess.Write);
                        int size;
                        byte[] buffer = new byte[4096];
                        do
                        {
                            size = zipInStream.Read(buffer, 0, buffer.Length);
                            fileStreamOut.Write(buffer, 0, size);
                        } while (size > 0);

                        fileStreamOut.Close();
                        entry = zipInStream.GetNextEntry();
                    }

                    if (fileStreamOut != null)
                        fileStreamOut.Close();
                    zipInStream.Close();
                }
                fileStreamIn.Close();
            }
        }
开发者ID:rcasady616,项目名称:SeleniumExtensions,代码行数:30,代码来源:FileInfoExtension.cs

示例4: TestCompressWithContentType

        public void TestCompressWithContentType()
        {
            var pipeline = PipelineFactory.CreateEmptySendPipeline();

            var component = new CompressMessage();
            var msgPart2 = MessageHelper.CreatePartFromString("<testmessage2></testmessage2>");
            var msgPart3 = MessageHelper.CreatePartFromString("<testmessage3></testmessage3>");
            msgPart2.ContentType = "application/xml";
            msgPart3.ContentType = "application/xml";
            var msg = MessageHelper.CreateFromString("<testmessage1></testmessage1>");
            msg.AddPart("invoice2", msgPart2, false);
            msg.AddPart("invoice3", msgPart3, false);
            msg.BodyPart.ContentType = "application/xml";
            pipeline.AddComponent(component, PipelineStage.Encode);

            var result = pipeline.Execute(msg);

            ZipInputStream zipInputStream = new ZipInputStream(result.BodyPart.GetOriginalDataStream());
            ZipEntry zipEntry = zipInputStream.GetNextEntry();
            while (zipEntry != null)
            {
                Guid g;
                Assert.IsTrue(Guid.TryParse(Path.GetFileNameWithoutExtension(zipEntry.Name), out g));
                Assert.AreEqual(".xml", Path.GetExtension(zipEntry.Name));
                zipEntry = zipInputStream.GetNextEntry();
            }
        }
开发者ID:robinhultman,项目名称:CompressMessage,代码行数:27,代码来源:CompressMessageTests.cs

示例5: WriteAllFilesToDb

        private static void WriteAllFilesToDb(MemoryStream stream)
        {
            ZipInputStream fileFromMemory = new ZipInputStream(stream);
            var entry = fileFromMemory.GetNextEntry();

            while (entry != null)
            {
                WriteFileToDb(fileFromMemory);

                entry = fileFromMemory.GetNextEntry();
            }
        }
开发者ID:sabrie,项目名称:TelerikAcademy,代码行数:12,代码来源:Upload.aspx.cs

示例6: RestoreFromFile

 private void RestoreFromFile(Stream file)
 {
         //
         //
         using (var store = IsolatedStorageFile.GetUserStoreForApplication()) {
                 using (var zip = new ZipInputStream(file)) {
                         try {
                                 while (true) {
                                         var ze = zip.GetNextEntry();
                                         if (ze == null) break;
                                         using (var f = new IsolatedStorageFileStream(ze.Name, FileMode.Create, store)) {
                                                 var fs = new byte[ze.Size];
                                                 zip.Read(fs, 0, fs.Length);
                                                 f.Write(fs, 0, fs.Length);
                                         }
                                 }
                         } catch {
                                 lblLastBackup.Text = StringResources.BackupAndRestorePage_Messages_RestoreFailed;
                                 App.ToastMe(StringResources.BackupAndRestorePage_Messages_RestoreFailed);
                                 return;
                         } finally {
                                 file.Close();
                                 ClearOldBackupFiles();
                                 App.ViewModel.IsRvDataChanged = true;
                         }
                 }
         }
         lblLastBackup.Text = StringResources.BackupAndRestorePage_Messages_RestoreSuccess;
         App.ToastMe(StringResources.BackupAndRestorePage_Messages_RestoreSuccess);
 }
开发者ID:tymiles003,项目名称:FieldService,代码行数:30,代码来源:BackupAndRestorePage.xaml.cs

示例7: Extract

        public void Extract(string path, string dest_dir)
        {
            ZipInputStream zipstream = new ZipInputStream(new FileStream( path, FileMode.Open));

              ZipEntry theEntry;
              while ((theEntry = zipstream.GetNextEntry()) != null) {
            string directoryName = Path.GetDirectoryName(theEntry.Name);
            string fileName      = Path.GetFileName(theEntry.Name);

            // create directory
            if (directoryName != String.Empty)
                Directory.CreateDirectory(directoryName);

            if (fileName != String.Empty) {
                FileStream streamWriter = File.Create( Path.Combine( dest_dir, theEntry.Name) );

                int size = 0;
                byte[] buffer = new byte[2048];
                while ((size = zipstream.Read(buffer, 0, buffer.Length)) > 0) {
                    streamWriter.Write(buffer, 0, size);
                }
                streamWriter.Close();
            }
              }
              zipstream.Close();
        }
开发者ID:GNOME,项目名称:capuchin,代码行数:26,代码来源:ZipExtracter.cs

示例8: Main

	public static void Main(string[] args)
	{
		ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
		
		ZipEntry theEntry;
		while ((theEntry = s.GetNextEntry()) != null) {
			Console.WriteLine("Name : {0}", theEntry.Name);
			Console.WriteLine("Date : {0}", theEntry.DateTime);
			Console.WriteLine("Size : (-1, if the size information is in the footer)");
			Console.WriteLine("      Uncompressed : {0}", theEntry.Size);
			Console.WriteLine("      Compressed   : {0}", theEntry.CompressedSize);
			int size = 2048;
			byte[] data = new byte[2048];
			
			Console.Write("Show Entry (y/n) ?");
			
			if (Console.ReadLine() == "y") {
//				System.IO.Stream st = File.Create("G:\\a.tst");
				while (true) {
					size = s.Read(data, 0, data.Length);
//					st.Write(data, 0, size);
					if (size > 0) {
							Console.Write(new ASCIIEncoding().GetString(data, 0, size));
					} else {
						break;
					}
				}
//				st.Close();
			}
			Console.WriteLine();
		}
		s.Close();
	}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:33,代码来源:ViewZipFile.cs

示例9: Parse

 public override string Parse()
 {
     if (!File.Exists(Context.Path))
         throw new FileNotFoundException("File " + Context.Path + " is not found");
     StringBuilder sb = new StringBuilder();
     using (ZipInputStream zipStream = new ZipInputStream(File.OpenRead(Context.Path)))
     {
         ZipEntry entry = zipStream.GetNextEntry();
         while (entry != null)
         {
             sb.AppendLine(entry.Name);
             entry = zipStream.GetNextEntry();
         }
     }
     return sb.ToString();
 }
开发者ID:iraychen,项目名称:toxy,代码行数:16,代码来源:ZipTextParser.cs

示例10: ImportMethod

        protected override void ImportMethod()
        {
            using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORT, STR_DOWNLOAD, 1, 0))
            {
                using (System.IO.TemporaryFile tmp = new System.IO.TemporaryFile(true))
                using (System.Net.WebClient wc = new System.Net.WebClient())
                {
                    wc.DownloadFile("http://www.globalcaching.eu/service/cachedistance.aspx?country=Netherlands&prefix=GC", tmp.Path);

                    using (var fs = System.IO.File.OpenRead(tmp.Path))
                    using (ZipInputStream s = new ZipInputStream(fs))
                    {
                        ZipEntry theEntry = s.GetNextEntry();
                        byte[] data = new byte[1024];
                        if (theEntry != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            while (true)
                            {
                                int size = s.Read(data, 0, data.Length);
                                if (size > 0)
                                {
                                    if (sb.Length == 0 && data[0] == 0xEF && size > 2)
                                    {
                                        sb.Append(System.Text.ASCIIEncoding.UTF8.GetString(data, 3, size - 3));
                                    }
                                    else
                                    {
                                        sb.Append(System.Text.ASCIIEncoding.UTF8.GetString(data, 0, size));
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }

                            XmlDocument doc = new XmlDocument();
                            doc.LoadXml(sb.ToString());
                            XmlElement root = doc.DocumentElement;
                            XmlNodeList nl = root.SelectNodes("wp");
                            if (nl != null)
                            {
                                Core.Geocaches.AddCustomAttribute(CUSTOM_ATTRIBUTE);
                                foreach (XmlNode n in nl)
                                {
                                    var gc = Utils.DataAccess.GetGeocache(Core.Geocaches, n.Attributes["code"].InnerText);
                                    if (gc != null)
                                    {
                                        string dist = Utils.Conversion.StringToDouble(n.Attributes["dist"].InnerText).ToString("000.0");
                                        gc.SetCustomAttribute(CUSTOM_ATTRIBUTE, dist);
                                    }
                                }
                            }
                        }
                    }

                }
            }
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:60,代码来源:GeocacheDistance.cs

示例11: UnZip

 protected Stream UnZip(Stream input)
 {
     var zipInputStream = new ZipInputStream(input);
     if (zipInputStream.GetNextEntry() == null)
         throw new ZipException("Can't unzip archive.");
     return zipInputStream;
 }
开发者ID:bdvsoft,项目名称:reader_wp8_OPDS,代码行数:7,代码来源:BaseFileLoader.cs

示例12: UnZip

    /// <summary>
    /// 解压缩文件(压缩文件中含有子目录)
    /// </summary>
    /// <param name="zipfilepath">待解压缩的文件路径</param>
    /// <param name="unzippath">解压缩到指定目录</param>
    /// <returns>解压后的文件列表</returns>
    public List<string> UnZip(string zipfilepath, string unzippath)
    {
        //解压出来的文件列表
        List<string> unzipFiles = new List<string>();

        //检查输出目录是否以“\\”结尾
        if (unzippath.EndsWith("\\") == false || unzippath.EndsWith(":\\") == false)
        {
            unzippath += "\\";
        }

        ZipInputStream s = new ZipInputStream(File.OpenRead(zipfilepath));
        ZipEntry theEntry;
        while ((theEntry = s.GetNextEntry()) != null)
        {
            string directoryName = Path.GetDirectoryName(unzippath);
            string fileName = Path.GetFileName(theEntry.Name);

            //生成解压目录【用户解压到硬盘根目录时,不需要创建】
            if (!string.IsNullOrEmpty(directoryName))
            {
                Directory.CreateDirectory(directoryName);
            }

            if (fileName != String.Empty)
            {
                //如果文件的压缩后大小为0那么说明这个文件是空的,因此不需要进行读出写入
                if (theEntry.CompressedSize == 0)
                    break;
                //解压文件到指定的目录
                directoryName = Path.GetDirectoryName(unzippath + theEntry.Name);
                //建立下面的目录和子目录
                Directory.CreateDirectory(directoryName);

                //记录导出的文件
                unzipFiles.Add(unzippath + theEntry.Name);

                FileStream streamWriter = File.Create(unzippath + theEntry.Name);

                int size = 2048;
                byte[] data = new byte[2048];
                while (true)
                {
                    size = s.Read(data, 0, data.Length);
                    if (size > 0)
                    {
                        streamWriter.Write(data, 0, size);
                    }
                    else
                    {
                        break;
                    }
                }
                streamWriter.Close();
            }
        }
        s.Close();
        GC.Collect();
        return unzipFiles;
    }
开发者ID:jongking,项目名称:XueXiaoWeiXin,代码行数:66,代码来源:ZipClass.cs

示例13: Unzip

        // 압축을 해제한다.
        private void Unzip(string zipfile)
        {
            // 풀고자 하는 압축 파일 이름
            ZipInputStream s = new ZipInputStream(File.OpenRead(zipfile));

            ZipEntry theEntry;
            while ((theEntry = s.GetNextEntry()) != null)
            {
                // 압축을 풀고자 하는 대상 폴더 이름이 "C:\test" 인 경우
                string fullname = @"C:\zipTest" + theEntry.Name;

                string directoryName = Path.GetDirectoryName(fullname);
                string fileName = Path.GetFileName(fullname);

                if (!Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName);

                if (fileName != String.Empty)
                {
                    FileStream streamWriter = File.Create(fullname);
                    int size = 2048;
                    byte[] data = new byte[2048];
                    while (true)
                    {
                        size = s.Read(data, 0, data.Length);
                        if (size > 0) streamWriter.Write(data, 0, size);
                        else break;
                    }
                    streamWriter.Close();
                }
            }
            s.Close();
        }
开发者ID:sunnamkim,项目名称:doc,代码行数:33,代码来源:WebForm1.aspx.cs

示例14: Main

	public static void Main(string[] args)
	{
		ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
		
		ZipEntry theEntry;
		while ((theEntry = s.GetNextEntry()) != null) {
			
			Console.WriteLine(theEntry.Name);
			
			string directoryName = Path.GetDirectoryName(theEntry.Name);
			string fileName      = Path.GetFileName(theEntry.Name);
			
			// create directory
			Directory.CreateDirectory(directoryName);
			
			if (fileName != String.Empty) {
				FileStream streamWriter = File.Create(theEntry.Name);
				
				int size = 2048;
				byte[] data = new byte[2048];
				while (true) {
					size = s.Read(data, 0, data.Length);
					if (size > 0) {
						streamWriter.Write(data, 0, size);
					} else {
						break;
					}
				}
				
				streamWriter.Close();
			}
		}
		s.Close();
	}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:34,代码来源:UnZipFile.cs

示例15: Add

        public override void Add (string path)
        {
            using (var file_stream = new FileStream (path, FileMode.Open, FileAccess.Read))
            using (var zip_stream = new ZipInputStream (file_stream)) {                
                ZipEntry entry;
                while ((entry = zip_stream.GetNextEntry ()) != null) {
                    if (!entry.IsFile) {
                        continue;
                    }
                    var extension = Path.GetExtension (entry.Name);
                    if (!parser_for_parts.SupportedFileExtensions.Contains (extension)) {
                        continue;
                    }

                    using (var out_stream = new MemoryStream ()) {
                        int size;
                        var buffer = new byte[2048];
                        do {
                            size = zip_stream.Read (buffer, 0, buffer.Length);
                            out_stream.Write (buffer, 0, size);
                        } while (size > 0);

                        out_stream.Seek (0, SeekOrigin.Begin);
                        try {
                            parser_for_parts.Add (out_stream, entry.Name);
                        } catch (NotSupportedException) {
                            
                        }
                    }
                }                
            }
        }
开发者ID:lothrop,项目名称:vernacular,代码行数:32,代码来源:XapParser.cs


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