public void SendReport(CrashReportDetails crashReport)
        {
            // Create xml file containing reportItems
            string prettyXml = "";

            using (System.IO.StringWriter stringWriter = new System.IO.StringWriter())
            {
                System.Xml.Serialization.XmlSerializerNamespaces ns = new System.Xml.Serialization.XmlSerializerNamespaces();
                ns.Add("", "");
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(crashReport.GetType(), crashReport.GetItemTypes());
                x.Serialize(stringWriter, crashReport, ns);
                prettyXml = stringWriter.ToString();
            }

            using (System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(new System.IO.MemoryStream()))
            {
                streamWriter.WriteLine(prettyXml);
                streamWriter.Flush();
                streamWriter.BaseStream.Position = 0;
                ZipStore.AddStream(System.IO.Compression.ZipStorer.Compression.Deflate, "crashrpt.xml", streamWriter.BaseStream, DateTime.Now, "");
            }

            ZipStore.Close();

            // Upload File
            HttpUploadFile(HttpUrl, ZipStream.ToArray(), FileParamName, FileName, "application/x-zip-compressed", HttpParams);
        }
Esempio n. 2
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);
        }