Esempio n. 1
0
        public static bool ApplyUpdateS2()         //step two, real apply update, if elevated
        {
            try
            {
                if (System.IO.File.Exists(zipfile))                 //il download ha fatto il suo lavoro
                {
                    using (System.IO.Compression.ZipStorer zs = System.IO.Compression.ZipStorer.Open(zipfile, System.IO.FileAccess.Read))
                    {
                        foreach (System.IO.Compression.ZipStorer.ZipFileEntry ze in zs.ReadCentralDir())
                        {
                            string fname = ze.FilenameInZip;
                            if (fname.StartsWith(mainpath))
                            {
                                fname = fname.Substring(mainpath.Length);
                            }

                            if (System.IO.File.Exists(fname))
                            {
                                System.IO.File.Delete(fname);
                            }

                            zs.ExtractFile(ze, "./" + fname);
                        }

                        zs.Close();
                        System.IO.File.Delete(zipfile);
                        return(true);
                    }
                }
            }
            catch (Exception ex) {}

            return(false);
        }