当前位置: 首页>>代码示例>>C#>>正文


C# ZipOutputStream.WriteByte方法代码示例

本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.ZipOutputStream.WriteByte方法的典型用法代码示例。如果您正苦于以下问题:C# ZipOutputStream.WriteByte方法的具体用法?C# ZipOutputStream.WriteByte怎么用?C# ZipOutputStream.WriteByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.SharpZipLib.Zip.ZipOutputStream的用法示例。


在下文中一共展示了ZipOutputStream.WriteByte方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PasswordCheckingWithDateInExtraData

        public void PasswordCheckingWithDateInExtraData()
        {
            MemoryStream ms = new MemoryStream();
            DateTime checkTime = new DateTime(2010, 10, 16, 0, 3, 28);

            using (ZipOutputStream zos = new ZipOutputStream(ms)) {
                zos.IsStreamOwner = false;
                zos.Password = "secret";
                ZipEntry ze = new ZipEntry("uno");
                ze.DateTime = new DateTime(1998, 6, 5, 4, 3, 2);

                ZipExtraData zed = new ZipExtraData();

                zed.StartNewEntry();

                zed.AddData(1);

                TimeSpan delta = checkTime.ToUniversalTime() - new System.DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime();
                int seconds = (int)delta.TotalSeconds;
                zed.AddLeInt(seconds);
                zed.AddNewEntry(0x5455);

                ze.ExtraData = zed.GetEntryData();
                zos.PutNextEntry(ze);
                zos.WriteByte(54);
            }

            ms.Position = 0;
            using (ZipInputStream zis = new ZipInputStream(ms)) {
                zis.Password = "secret";
                ZipEntry uno = zis.GetNextEntry();
                byte theByte = (byte)zis.ReadByte();
                Assert.AreEqual(54, theByte);
                Assert.AreEqual(-1, zis.ReadByte());
                Assert.AreEqual(checkTime, uno.DateTime);
            }
        }
开发者ID:firestrand,项目名称:SharpZipLib,代码行数:37,代码来源:ZipTests.cs

示例2: ReadAndWriteZip64NonSeekable

        public void ReadAndWriteZip64NonSeekable()
        {
            MemoryStream msw = new MemoryStreamWithoutSeek();
            using (ZipOutputStream outStream = new ZipOutputStream(msw))
            {
                outStream.UseZip64 = UseZip64.On;

                outStream.IsStreamOwner = false;
                outStream.PutNextEntry(new ZipEntry("StripedMarlin"));
                outStream.WriteByte(89);

                outStream.PutNextEntry(new ZipEntry("StripedMarlin2"));
                outStream.WriteByte(89);

                outStream.Close();
            }

            Assert.IsTrue(ZipTesting.TestArchive(msw.ToArray()));

            msw.Position = 0;

            using (ZipInputStream zis = new ZipInputStream(msw))
            {
                while ( zis.GetNextEntry() != null )
                {
                    int len = 0;
                    int bufferSize = 1024;
                    byte[] buffer = new byte[bufferSize];
                    while ((len = zis.Read(buffer, 0, bufferSize)) > 0) {
                        // Reading the data is enough
                    }
                }
            }
        }
开发者ID:firestrand,项目名称:SharpZipLib,代码行数:34,代码来源:ZipTests.cs

示例3: Zip64Descriptor

        public void Zip64Descriptor()
        {
            MemoryStream msw = new MemoryStreamWithoutSeek();
            ZipOutputStream outStream = new ZipOutputStream(msw);
            outStream.UseZip64 = UseZip64.Off;

            outStream.IsStreamOwner = false;
            outStream.PutNextEntry(new ZipEntry("StripedMarlin"));
            outStream.WriteByte(89);
            outStream.Close();

            Assert.IsTrue(ZipTesting.TestArchive(msw.ToArray()));

            msw = new MemoryStreamWithoutSeek();
            outStream = new ZipOutputStream(msw);
            outStream.UseZip64 = UseZip64.On;

            outStream.IsStreamOwner = false;
            outStream.PutNextEntry(new ZipEntry("StripedMarlin"));
            outStream.WriteByte(89);
            outStream.Close();

            Assert.IsTrue(ZipTesting.TestArchive(msw.ToArray()));
        }
开发者ID:firestrand,项目名称:SharpZipLib,代码行数:24,代码来源:ZipTests.cs

示例4: AddErrorReport


//.........这里部分代码省略.........
                    mlInfos["DictionaryFileAttributes"] = new FileInfo(Dictionary.DictionaryPath).Attributes.ToString();
                    mlInfos["DictionaryACL"] = new FileInfo(Dictionary.DictionaryPath).GetAccessControl().GetSecurityDescriptorSddlForm(System.Security.AccessControl.AccessControlSections.All);
                }
                mlInfos["LoggedinUser"] = string.Format("{0} - {1}", Environment.UserName, new System.Security.Principal.NTAccount(Environment.UserName).Translate(typeof(System.Security.Principal.SecurityIdentifier)).Value);
            }
            catch
            {
                mlInfos["DictionaryFile"] = "Readout failed.";
            }

            //get the extensions
            Dictionary<string, string> extInfos = new Dictionary<string, string>();
            try
            {
                if (Dictionary != null && Dictionary.DictionaryDAL.Extensions.Count > 0)
                    foreach (IExtension extension in Dictionary.DictionaryDAL.Extensions)
                        extInfos["Extension"] = extension.ToString() + " - (" + extension.Id + ")";
                else
                    extInfos["Extensions"] = "No extensions.";
            }
            catch
            {
                extInfos["Extensions"] = "Readout failed.";
            }

            //fetch some basic system information
            Dictionary<string, string> sysInfos = new Dictionary<string, string>();
            try
            {
                sysInfos["OSVersion"] = System.Environment.OSVersion.ToString();
                sysInfos["IEVersion"] = MLifter.Generics.Methods.GetInternetExplorerVersion().ToString();
                sysInfos["CLRVersion"] = System.Environment.Version.ToString();
                sysInfos["SystemDirectory"] = System.Environment.SystemDirectory;
                sysInfos["WMPVersion"] = MLifter.Generics.Methods.GetWindowsMediaPlayerVersion().ToString();
            }
            catch
            {
                sysInfos["SystemInformation"] = "Readout failed.";
            }
            #endregion

            #region write data
            //add the XSL to the output
            FileInfo errorReportStylesheet = new FileInfo(Path.Combine(Path.Combine(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), Path.Combine(Properties.Settings.Default.AppDataFolder, Properties.Settings.Default.AppDataFolderDesigns)), @"System\ErrorHandler\default.xsl"));
            if (errorReportStylesheet.Exists)
            {
                ZipEntry styleEntry = new ZipEntry("ErrorReport.xsl");
                stream.PutNextEntry(styleEntry);
                using (FileStream styleStream = errorReportStylesheet.OpenRead())
                {
                    try
                    {
                        int i;
                        do
                        {
                            i = styleStream.ReadByte();
                            if (i != -1) stream.WriteByte((byte)i);
                        } while (i != -1);
                    }
                    catch (IOException) { }
                }
            }

            //write the error report
            ZipEntry entry = new ZipEntry("ErrorReport.xml");
            stream.PutNextEntry(entry);

            XmlWriterSettings settings = new XmlWriterSettings() { CloseOutput = true, Encoding = Encoding.Unicode, Indent = true };
            XmlWriter errorReportXML = XmlWriter.Create(stream, settings);
            errorReportXML.WriteStartDocument();
            if (errorReportStylesheet.Exists)
            {
                errorReportXML.WriteProcessingInstruction("xml-stylesheet", string.Format("type='Text/xsl' href='{0}'", errorReportStylesheet.FullName));
                errorReportXML.WriteProcessingInstruction("xml-stylesheet", string.Format("type='Text/xsl' href='{0}'", "ErrorReport.xsl"));
            }

            errorReportXML.WriteComment(String.Format("{0} {1} Error Report, generated {2}", AssemblyData.Title, AssemblyData.AssemblyVersion, System.DateTime.Now.ToString()));
            errorReportXML.WriteStartElement("ErrorReport");

            errorReportXML.WriteStartElement("MLInformation");
            foreach (KeyValuePair<string, string> pair in mlInfos)
                errorReportXML.WriteElementString(pair.Key, pair.Value);
            errorReportXML.WriteEndElement();

            errorReportXML.WriteStartElement("ExtensionsInformation");
            foreach (KeyValuePair<string, string> pair in extInfos)
                errorReportXML.WriteElementString(pair.Key, pair.Value);
            errorReportXML.WriteEndElement();

            errorReportXML.WriteStartElement("SystemInformation");
            foreach (KeyValuePair<string, string> pair in sysInfos)
                errorReportXML.WriteElementString(pair.Key, pair.Value);
            errorReportXML.WriteEndElement();

            XMLWriteException(errorReportXML, exception);

            errorReportXML.WriteEndElement();
            errorReportXML.Flush();
            #endregion
        }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:101,代码来源:ErrorReportGenerator.cs


注:本文中的ICSharpCode.SharpZipLib.Zip.ZipOutputStream.WriteByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。