Example #1
0
        public static bool ExtractZip(string zipFile, string dest, Action<string> onProgress, Action<string> onError)
        {
            if (!File.Exists(zipFile))
            {
                onError("Invalid path: " + zipFile);
                return false;
            }

            List<string> extracted = new List<string>();
            try
            {
                var z = new ZipInputStream(File.OpenRead(zipFile));
                z.ExtractZip(dest, extracted, s => onProgress("Extracting " + s));
            }
            catch (SharpZipBaseException)
            {
                foreach (var f in extracted)
                    File.Delete(f);

                onError("Invalid archive");
                return false;
            }

            return true;
        }