Esempio n. 1
0
        // TODO: this belongs in FileSystem/ZipFile
        static void ExtractZip(this ZipInputStream z, string destPath, List <string> extracted, Action <string> onProgress)
        {
            foreach (var entry in z.GetEntries())
            {
                if (!entry.IsFile)
                {
                    continue;
                }

                onProgress(entry.Name);

                Directory.CreateDirectory(Path.Combine(destPath, Path.GetDirectoryName(entry.Name)));
                var path = Path.Combine(destPath, entry.Name);
                extracted.Add(path);

                using (var f = File.Create(path))
                {
                    int    bufSize = 2048;
                    byte[] buf     = new byte[bufSize];
                    while ((bufSize = z.Read(buf, 0, buf.Length)) > 0)
                    {
                        f.Write(buf, 0, bufSize);
                    }
                }
            }

            z.Close();
        }
Esempio n. 2
0
        // TODO: this belongs in FileSystem/ZipFile
        static void ExtractZip(this ZipInputStream z, string destPath, List <string> extracted, Action <string> onProgress)
        {
            foreach (var entry in z.GetEntries())
            {
                if (!entry.IsFile)
                {
                    continue;
                }

                onProgress(entry.Name);

                Directory.CreateDirectory(Path.Combine(destPath, Path.GetDirectoryName(entry.Name)));
                var path = Path.Combine(destPath, entry.Name);
                extracted.Add(path);

                using (var f = File.Create(path))
                    z.CopyTo(f);
            }

            z.Close();
        }