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


C# ZipInputStream.Close方法代码示例

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


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

示例1: UnpackData

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Unzip a byte array and return unpacked data
		/// </summary>
		/// <param name="data">Byte array containing data to be unzipped</param>
		/// <returns>unpacked data</returns>
		/// ------------------------------------------------------------------------------------
		public static byte[] UnpackData(byte[] data)
		{
			if (data == null)
				return null;
			try
			{
				MemoryStream memStream = new MemoryStream(data);
				ZipInputStream zipStream = new ZipInputStream(memStream);
				zipStream.GetNextEntry();
				MemoryStream streamWriter = new MemoryStream();
				int size = 2048;
				byte[] dat = new byte[2048];
				while (true)
				{
					size = zipStream.Read(dat, 0, dat.Length);
					if (size > 0)
					{
						streamWriter.Write(dat, 0, size);
					}
					else
					{
						break;
					}
				}
				streamWriter.Close();
				zipStream.CloseEntry();
开发者ID:sillsdev,项目名称:WorldPad,代码行数:33,代码来源:DataZip.cs

示例2: UnZipFile

 public static void UnZipFile(string[] args)
 {
     ZipInputStream zipInputStream = new ZipInputStream((Stream) File.OpenRead(args[0].Trim()));
       string directoryName = Path.GetDirectoryName(args[1].Trim());
       if (!Directory.Exists(args[1].Trim()))
     Directory.CreateDirectory(directoryName);
       ZipEntry nextEntry;
       while ((nextEntry = zipInputStream.GetNextEntry()) != null)
       {
     string fileName = Path.GetFileName(nextEntry.Name);
     if (fileName != string.Empty)
     {
       FileStream fileStream = File.Create(args[1].Trim() + fileName);
       byte[] buffer = new byte[2048];
       while (true)
       {
     int count = zipInputStream.Read(buffer, 0, buffer.Length);
     if (count > 0)
       fileStream.Write(buffer, 0, count);
     else
       break;
       }
       fileStream.Close();
     }
       }
       zipInputStream.Close();
 }
开发者ID:wangyuanxun,项目名称:DataOperator,代码行数:27,代码来源:UnZipTools.cs

示例3: DeserializeBlockFromZippedXML

 public Block DeserializeBlockFromZippedXML(String zipFilePath, String blockFileName)
 {
     FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Open);
     ZipInputStream zippedStream = new ZipInputStream(zipFileStream);
     ZipEntry zipEntry;
     Block block = null;
     while ((zipEntry = zippedStream.GetNextEntry()) != null)
     {
         if (zipEntry.Name == blockFileName)
         {
             block = (Block)xmls.Deserialize(zippedStream);
             break;
         }
     }
     zippedStream.Close();
     // the following is a workaround. We took a lot of data before we started recording
     // the rfState. Luckily, almost all of this data was taken in the same rf state.
     // Here, if no rfState is found in the block it is assigned the default, true.
     try
     {
         bool rfState = (bool)block.Config.Settings["rfState"];
     }
     catch (Exception)
     {
         block.Config.Settings.Add("rfState", true);
     }
     return block;
 }
开发者ID:ColdMatter,项目名称:EDMSuite,代码行数:28,代码来源:BlockSerializer.cs

示例4: Unzip

        public static string Unzip(string fileNameZip)
        {
            string path = Path.GetDirectoryName(fileNameZip);
            string folderName = Path.Combine(path, Path.GetFileNameWithoutExtension(fileNameZip));
            CreateDirectory(folderName);

            ZipInputStream strmZipInputStream = new ZipInputStream(File.OpenRead(fileNameZip));
            ZipEntry entry;
            while ((entry = strmZipInputStream.GetNextEntry()) != null)
            {
                FileStream fs = File.Create(Path.Combine(folderName, entry.Name));
                int size = 2048;
                byte[] data = new byte[2048];

                while (true)
                {
                    size = strmZipInputStream.Read(data, 0, data.Length);
                    if (size > 0)
                        fs.Write(data, 0, size);
                    else
                        break;
                }
                fs.Close();
            }
            strmZipInputStream.Close();
            return folderName;
        }
开发者ID:whztt07,项目名称:EnergyAnalysisForDynamo,代码行数:27,代码来源:ZipUtil.cs

示例5: 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

示例6: 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

示例7: GetInputStream

        public override Stream GetInputStream(UploadedFile file)
        {
            FileStream fileS = null;
            ZipInputStream zipS = null;

            try
            {
                string path = GetZipPath(file);

                fileS = File.OpenRead(path);
                zipS = new ZipInputStream(fileS);

                zipS.GetNextEntry();

                return zipS;
            }
            catch
            {
                if (fileS != null)
                    fileS.Close();

                if (zipS != null)
                    zipS.Close();

                return null;
            }
        }
开发者ID:bmsolutions,项目名称:mvc2inaction,代码行数:27,代码来源:ZipUploadStreamProvider.cs

示例8: File

        /// <summary>
        /// 解压缩文件
        /// </summary>
        /// <param name="zipPath">源文件</param>
        /// <param name="directory">目标文件</param>
        /// <param name="password">密码</param>
        public void File(string zipPath, string directory, string password = null) {
            FileInfo objFile = new FileInfo(zipPath);
            if (!objFile.Exists || !objFile.Extension.ToUpper().Equals(".ZIP")) return;
            FileDirectory.DirectoryCreate(directory);

            ZipInputStream objZIS = new ZipInputStream(System.IO.File.OpenRead(zipPath));
            if (!password.IsNullEmpty()) objZIS.Password = password;
            ZipEntry objEntry;
            while ((objEntry = objZIS.GetNextEntry()) != null) {
                string directoryName = Path.GetDirectoryName(objEntry.Name);
                string fileName = Path.GetFileName(objEntry.Name);
                if (directoryName != String.Empty) FileDirectory.DirectoryCreate(directory + directoryName);
                if (fileName != String.Empty) {
                    FileStream streamWriter = System.IO.File.Create(Path.Combine(directory, objEntry.Name));
                    int size = 2048;
                    byte[] data = new byte[2048];
                    while (true) {
                        size = objZIS.Read(data, 0, data.Length);
                        if (size > 0) {
                            streamWriter.Write(data, 0, size);
                        } else {
                            break;
                        }
                    }
                    streamWriter.Close();
                }
            }
            objZIS.Close();
        }
开发者ID:pczy,项目名称:Pub.Class,代码行数:35,代码来源:Decompress.cs

示例9: 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

示例10: UnZipFile

 public static bool UnZipFile(string InputPathOfZipFile, string NewName)
 {
     bool ret = true;
     try
     {
         if (File.Exists(InputPathOfZipFile))
         {
             string baseDirectory = Path.GetDirectoryName(InputPathOfZipFile);
             using (ZipInputStream ZipStream = new
             ZipInputStream(File.OpenRead(InputPathOfZipFile)))
             {
                 ZipEntry theEntry;
                 while ((theEntry = ZipStream.GetNextEntry()) != null)
                 {
                     if (theEntry.IsFile)
                     {
                         if (theEntry.Name != "")
                         {
                             string strNewFile = @"" + baseDirectory + @"\" +
                                                 NewName;
                             if (File.Exists(strNewFile))
                             {
                                 //continue;
                             }
                             using (FileStream streamWriter = File.Create(strNewFile))
                             {
                                 int size = 2048;
                                 byte[] data = new byte[2048];
                                 while (true)
                                 {
                                     size = ZipStream.Read(data, 0, data.Length);
                                     if (size > 0)
                                         streamWriter.Write(data, 0, size);
                                     else
                                         break;
                                 }
                                 streamWriter.Close();
                             }
                         }
                     }
                     else if (theEntry.IsDirectory)
                     {
                         string strNewDirectory = @"" + baseDirectory + @"\" +
                                                 theEntry.Name;
                         if (!Directory.Exists(strNewDirectory))
                         {
                             Directory.CreateDirectory(strNewDirectory);
                         }
                     }
                 }
                 ZipStream.Close();
             }
         }
     }
     catch (Exception ex)
     {
         ret = false;
     }
     return ret;
 }
开发者ID:slagovskiy,项目名称:psa,代码行数:60,代码来源:PSA.Robot.Service.Cache.cs

示例11: ZipInputStream

 /// <summary>
 /// 解压缩文件
 /// </summary>
 /// <param name="输入压缩文件路径">要解压的压缩文件</param>
 /// <param name="解压缩目录">解压目标目录路径</param>
 public static void 解压缩(string 输入压缩文件路径, string 解压缩目录)
 {
     ZipInputStream inputStream = new ZipInputStream(File.OpenRead(输入压缩文件路径));
     ZipEntry theEntry;
     while ((theEntry = inputStream.GetNextEntry()) != null)
     {
         解压缩目录 += "/";
         string fileName = Path.GetFileName(theEntry.Name);
         string path = Path.GetDirectoryName(解压缩目录 + theEntry.Name) + "/";
         Directory.CreateDirectory(path);//生成解压目录
         if (fileName != String.Empty)
         {
             FileStream streamWriter = File.Create(path + fileName);//解压文件到指定的目录 
             int size = 2048;
             byte[] data = new byte[2048];
             while (true)
             {
                 size = inputStream.Read(data, 0, data.Length);
                 if (size > 0)
                 {
                     streamWriter.Write(data, 0, size);
                 }
                 else
                 {
                     break;
                 }
             }
             streamWriter.Close();
         }
     }
     inputStream.Close();
 }
开发者ID:manasheep,项目名称:Core3,代码行数:37,代码来源:SharpZip.cs

示例12: 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

示例13: KarFile

        public KarFile(string fileName, ReportProgressFunction ReportProgress)
        {
            _fileName = fileName;
            _directory = FileFunctions.CreateTempoaryDirectory();
            using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            using (ZipInputStream zip = new ZipInputStream(file))
            {
                while (true)
                {
                    ZipEntry item = zip.GetNextEntry();
                    if (item == null)
                    {
                        break;
                    }

                    string itemDirectory = Path.GetDirectoryName(item.Name);
                    string itemName = Path.GetFileName(item.Name);

                    string outputDirectory = Path.Combine(_directory, itemDirectory);
                    FileFunctions.CreateDirectory(outputDirectory, ReportProgress);

                    string outputName = Path.Combine(outputDirectory, itemName);
                    StreamFunctions.ExportUntilFail(outputName, zip, ReportProgress);
                }

                zip.Close();
            }
        }
开发者ID:swish-climate-impact-assessment,项目名称:swish-kepler-actors,代码行数:28,代码来源:KarFile.cs

示例14: UnZipFile

 public void UnZipFile(string ZipedFile, string UnZipFile)
 {
     ZipInputStream zipInputStream = new ZipInputStream(File.OpenRead(ZipedFile));
     ZipEntry nextEntry;
     while ((nextEntry = zipInputStream.GetNextEntry()) != null)
     {
         string directoryName = Path.GetDirectoryName(UnZipFile);
         string fileName = Path.GetFileName(nextEntry.Name);
         Directory.CreateDirectory(directoryName);
         if (fileName != string.Empty)
         {
             FileStream fileStream = File.OpenWrite(UnZipFile);
             byte[] array = new byte[2048];
             while (true)
             {
                 int num = zipInputStream.Read(array, 0, array.Length);
                 if (num <= 0)
                 {
                     break;
                 }
                 fileStream.Write(array, 0, num);
             }
             fileStream.Close();
         }
     }
     zipInputStream.Close();
 }
开发者ID:wangshu,项目名称:NY_HACK,代码行数:27,代码来源:clsCompression.cs

示例15: UnZipFile

        public static bool UnZipFile(string zipPathAndFile, string outputFolder, string password, bool deleteZipFile)
        {
            try
            {
                ZipInputStream s = new ZipInputStream(File.OpenRead(zipPathAndFile));
                if (password != null && password != String.Empty)
                    s.Password = password;
                ZipEntry theEntry;
                string tmpEntry = String.Empty;
                while ((theEntry = s.GetNextEntry()) != null)
                {
                    string directoryName = outputFolder;
                    string fileName = Path.GetFileName(theEntry.Name);

                    if (directoryName != "")
                    {
                        //if(Directory.Exists(
                        Directory.CreateDirectory(directoryName);
                    }
                    if (fileName != String.Empty)
                    {
                        if (theEntry.Name.IndexOf(".ini") < 0)
                        {
                            string fullPath = directoryName + "\\" + theEntry.Name;
                            fullPath = fullPath.Replace("\\ ", "\\");
                            string fullDirPath = Path.GetDirectoryName(fullPath);
                            if (!Directory.Exists(fullDirPath)) Directory.CreateDirectory(fullDirPath);
                            FileStream streamWriter = File.Create(fullPath);
                            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.Flush();
                            streamWriter.Close();
                        }
                    }
                }
                //s.Flush();
                s.Close();
                if (deleteZipFile)
                    File.Delete(zipPathAndFile);
                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                return false;
            }
        }
开发者ID:harryho,项目名称:demo-fx-trading-platform-prototype,代码行数:59,代码来源:ZipUtil.cs


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