本文整理汇总了C#中Ionic.Zip.ZipEntry.SetEntryTimes方法的典型用法代码示例。如果您正苦于以下问题:C# ZipEntry.SetEntryTimes方法的具体用法?C# ZipEntry.SetEntryTimes怎么用?C# ZipEntry.SetEntryTimes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic.Zip.ZipEntry
的用法示例。
在下文中一共展示了ZipEntry.SetEntryTimes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutNextEntry
/// <summary>
/// Specify the name of the next entry that will be written to the zip file.
/// </summary>
///
/// <remarks>
/// <para>
/// Call this method just before calling <see cref="Write(byte[], int, int)"/>, to
/// specify the name of the entry that the next set of bytes written to
/// the <c>ZipOutputStream</c> belongs to. All subsequent calls to <c>Write</c>,
/// until the next call to <c>PutNextEntry</c>,
/// will be inserted into the named entry in the zip file.
/// </para>
///
/// <para>
/// If the <paramref name="entryName"/> used in <c>PutNextEntry()</c> ends in
/// a slash, then the entry added is marked as a directory. Because directory
/// entries do not contain data, a call to <c>Write()</c>, before an
/// intervening additional call to <c>PutNextEntry()</c>, will throw an
/// exception.
/// </para>
///
/// <para>
/// If you don't call <c>Write()</c> between two calls to
/// <c>PutNextEntry()</c>, the first entry is inserted into the zip file as a
/// file of zero size. This may be what you want.
/// </para>
///
/// <para>
/// Because <c>PutNextEntry()</c> closes out the prior entry, if any, this
/// method may throw if there is a problem with the prior entry.
/// </para>
///
/// <para>
/// This method returns the <c>ZipEntry</c>. You can modify public properties
/// on the <c>ZipEntry</c>, such as <see cref="ZipEntry.Encryption"/>, <see
/// cref="ZipEntry.Password"/>, and so on, until the first call to
/// <c>ZipOutputStream.Write()</c>, or until the next call to
/// <c>PutNextEntry()</c>. If you modify the <c>ZipEntry</c> <em>after</em>
/// having called <c>Write()</c>, you may get a runtime exception, or you may
/// silently get an invalid zip archive.
/// </para>
///
/// </remarks>
///
/// <example>
///
/// This example shows how to create a zip file, using the
/// <c>ZipOutputStream</c> class.
///
/// <code>
/// private void Zipup()
/// {
/// using (FileStream fs raw = File.Open(_outputFileName, FileMode.Create, FileAccess.ReadWrite ))
/// {
/// using (var output= new ZipOutputStream(fs))
/// {
/// output.Password = "VerySecret!";
/// output.Encryption = EncryptionAlgorithm.WinZipAes256;
/// output.PutNextEntry("entry1.txt");
/// byte[] buffer= System.Text.Encoding.ASCII.GetBytes("This is the content for entry #1.");
/// output.Write(buffer,0,buffer.Length);
/// output.PutNextEntry("entry2.txt"); // this will be zero length
/// output.PutNextEntry("entry3.txt");
/// buffer= System.Text.Encoding.ASCII.GetBytes("This is the content for entry #3.");
/// output.Write(buffer,0,buffer.Length);
/// }
/// }
/// }
/// </code>
/// </example>
///
/// <param name="entryName">
/// The name of the entry to be added, including any path to be used
/// within the zip file.
/// </param>
///
/// <returns>
/// The ZipEntry created.
/// </returns>
///
public ZipEntry PutNextEntry(String entryName)
{
if (_disposed)
{
_exceptionPending = true;
throw new System.InvalidOperationException("The stream has been closed.");
}
_FinishCurrentEntry();
_currentEntry = ZipEntry.CreateForZipOutputStream(entryName);
_currentEntry._container = new ZipContainer(this);
_currentEntry._BitField |= 0x0008; // workitem 8932
_currentEntry.SetEntryTimes(DateTime.Now, DateTime.Now, DateTime.Now);
_currentEntry.CompressionLevel = CompressionLevel;
_currentEntry.Encryption = Encryption;
_currentEntry.Password = _password;
if (entryName.EndsWith("/")) _currentEntry.MarkAsDirectory();
_currentEntry.EmitTimesInWindowsFormatWhenSaving = ((_timestamp & ZipEntryTimestamp.Windows) != 0);
//.........这里部分代码省略.........