Exemple #1
0
    private void UnZipOneFile(object _file)
    {
        OneFile oneFile = (OneFile)_file;

        using (ZipInputStream zipInputStream = new ZipInputStream(File.Open(this.zipFileName, 3, 1, 3)))
        {
            for (int i = 0; i < oneFile.entryCounter; i++)
            {
                zipInputStream.GetNextEntry();
            }
            using (FileStream fileStream = File.Create(oneFile.filePath))
            {
                int    num   = 2048;
                byte[] array = new byte[2048];
                while (true)
                {
                    try
                    {
                        num = zipInputStream.Read(array, 0, array.Length);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError("zipFile.Read " + ex.ToString());
                        break;
                    }
                    if (num <= 0)
                    {
                        break;
                    }
                    fileStream.Write(array, 0, num);
                }
            }
            this.unZipProgress = (float)zipInputStream.get_Position() / (float)this.fileSize;
        }
    }