本文整理汇总了C#中ExtractExistingFileAction类的典型用法代码示例。如果您正苦于以下问题:C# ExtractExistingFileAction类的具体用法?C# ExtractExistingFileAction怎么用?C# ExtractExistingFileAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExtractExistingFileAction类属于命名空间,在下文中一共展示了ExtractExistingFileAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnzipArchiveTask
public UnzipArchiveTask(string @zipArchiveFilename, string to, DestinationCleanOptions options, Path path, ExtractExistingFileAction? explicitExistingFileAction)
: base(path)
{
_zipArchiveFilename = zipArchiveFilename;
_to = to;
_options = options;
_explicitExistingFileAction = explicitExistingFileAction;
}
示例2: Unpack
public void Unpack(ExtractExistingFileAction existingFileAction)
{
using (ZipFile modZip = ZipFile.Read(this.location))
{
foreach (ZipEntry zipEntry in modZip)
{
zipEntry.Extract(FileSystemUtils.unPackagedDir, existingFileAction);
}
}
}
示例3: Extract
/// <summary>
///
/// </summary>
/// <param name="archiveFile"></param>
/// <param name="targetDirectory"></param>
/// <param name="overwrite"></param>
/// <param name="password"></param>
public static void Extract(string archiveFile, string targetDirectory, ExtractExistingFileAction overwrite, string password)
{
using (var zip = ZipFile.Read(archiveFile))
{
foreach (var entry in zip)
{
entry.ExtractWithPassword(targetDirectory, (Ionic.Zip.ExtractExistingFileAction)((int)overwrite), password);
}
}
}
示例4: ExtractFileFromZip
/// <summary>ZIPファイルを解凍</summary>
/// <param name="zipFileName">ZIPファイル名</param>
/// <param name="directoryToUnZip">解凍先</param>
/// <param name="selectionDlgt">ファイル選択デリゲード</param>
/// <param name="selectionCriteriaInfo">ファイル選択基準情報</param>
/// <param name="extractExistingFile">上書き時の動作</param>
/// <param name="enc">エンコーディング</param>
/// <param name="zipPassword">パスワード</param>
public void ExtractFileFromZip(
string zipFileName, string directoryToUnZip,
SelectionDelegate selectionDlgt,
object selectionCriteriaInfo,
ExtractExistingFileAction extractExistingFile,
Encoding enc, string zipPassword)
{
#region ファイル選択
// ファイル選択デリゲード
if (selectionCriteriaInfo != null)
{
// 指定のデリゲード
this._selectionDlgt = selectionDlgt;
// ファイル選択基準情報
this._selectionCriteriaInfo = selectionCriteriaInfo;
}
#endregion
// ZipFileを取得
ZipFile zip = this.GetZipFile(zipFileName, enc, zipPassword);
using (zip) // 使い終ったら「zip.Dispose」する。
{
//// ● フォルダのアーカイブ
//zip.ExtractAll(directoryToUnZip, extractExistingFile);
// ● ファイルを個別に追加する(UOCにて実装)。
foreach (ZipEntry ze in zip.Entries)
{
// 圧縮対象ファイルを選択(ファイル選択デリゲードを使用)
if (this.SelectionDlgt(ze.FileName, selectionCriteriaInfo))
{
// デフォルトでは、zipファイルの位置に解凍される。
ze.Extract(directoryToUnZip, extractExistingFile);
}
}
}
}
示例5: ExistingFilesAction
public UnzipOptions ExistingFilesAction(ExtractExistingFileAction action)
{
_explicitExistingFileAction = action;
return this;
}
示例6: ExtractWithPassword
/// <summary>
/// Extract the entry to the filesystem, starting at the specified base directory, and
/// using the specified behavior when extraction would overwrite an existing file.
/// </summary>
///
/// <remarks>
/// See the remarks on the <see cref="LastModified"/> property, for some details
/// about how the last modified time of the created file is set.
/// </remarks>
///
/// <param name="baseDirectory">the pathname of the base directory</param>
///
/// <param name="extractExistingFile">The action to take if extraction would
/// overwrite an existing file.</param>
///
/// <param name="password">The Password to use for decrypting the entry.</param>
public void ExtractWithPassword(string baseDirectory, ExtractExistingFileAction extractExistingFile, string password)
{
ExtractExistingFile = extractExistingFile;
InternalExtract(baseDirectory, null, password);
}
示例7: Extract
/// <summary>
/// Extract the entry to a file in the filesystem, using the specified behavior
/// when extraction would overwrite an existing file.
/// </summary>
/// <remarks>
/// <para>
/// See the remarks on the <see cref="LastModified"/> property, for some details
/// about how the last modified time of the file is set after extraction.
/// </para>
/// </remarks>
/// <param name="extractExistingFile">The action to take if extraction would
/// overwrite an existing file.</param>
public void Extract(ExtractExistingFileAction extractExistingFile)
{
ExtractExistingFile = extractExistingFile;
InternalExtract(".", null, null);
}
示例8: ExtractWithPassword
/// <summary>
/// Extract the entry to the filesystem, starting at the specified base
/// directory, and using the specified behavior when extraction would
/// overwrite an existing file.
/// </summary>
///
/// <remarks>
/// See the remarks on the <see cref="LastModified"/> property, for some
/// details about how the last modified time of the created file is set.
/// </remarks>
///
/// <param name="baseDirectory">the pathname of the base directory</param>
///
/// <param name="extractExistingFile">The action to take if extraction would
/// overwrite an existing file.</param>
///
/// <param name="password">The Password to use for decrypting the entry.</param>
public void ExtractWithPassword(string baseDirectory, ExtractExistingFileAction extractExistingFile, string password)
{
ExtractExistingFile = extractExistingFile;
InternalExtractToBaseDir(baseDirectory, password, _container, _Source, FileName);
}
示例9: Unzipper
public Unzipper(string zipFilePath, ExtractExistingFileAction extractionStratedy = ExtractExistingFileAction.OverwriteSilently)
{
this.Path = zipFilePath;
this.ExtractionStrategy = extractionStratedy;
}
示例10: ExtractSelectedEntries
/// <summary>
/// Selects and Extracts a set of Entries from the ZipFile.
/// </summary>
///
/// <remarks>
/// <para>
/// The entries are extracted into the current working directory. When extraction would would
/// overwrite an existing filesystem file, the action taken is as specified in the
/// <paramref name="extractExistingFile"/> parameter.
/// </para>
///
/// <para>
/// For information on the syntax of the string describing the entry selection criteria,
/// see <see cref="AddSelectedFiles(String)" />.
/// </para>
/// </remarks>
///
/// <example>
/// This example shows how extract all XML files modified after 15 January 2009,
/// overwriting any existing files.
/// <code>
/// using (ZipFile zip = ZipFile.Read(zipArchiveName))
/// {
/// zip.ExtractSelectedEntries("name = *.xml and mtime > 2009-01-15",
/// ExtractExistingFileAction.OverwriteSilently);
/// }
/// </code>
/// </example>
///
/// <param name="selectionCriteria">the selection criteria for entries to extract.</param>
///
/// <param name="extractExistingFile">
/// The action to take if extraction would overwrite an existing file.
/// </param>
internal void ExtractSelectedEntries(String selectionCriteria, ExtractExistingFileAction extractExistingFile)
{
foreach (ZipEntry e in SelectEntries(selectionCriteria))
{
e.Password = _Password; // possibly null
e.Extract(extractExistingFile);
}
}
示例11: ExtractAll
/// <summary>
/// Extracts all of the items in the zip archive, to the specified path in the
/// filesystem, using the specified behavior when extraction would overwrite an
/// existing file.
/// </summary>
///
/// <remarks>
///
/// <para>
/// This method will extract all entries in the <c>ZipFile</c> to the specified
/// path. For an extraction that would overwrite an existing file, the behavior
/// is dictated by <paramref name="extractExistingFile"/>, which overrides any
/// setting you may have made on individual ZipEntry instances.
/// </para>
///
/// <para>
/// The action to take when an extract would overwrite an existing file
/// applies to all entries. If you want to set this on a per-entry basis,
/// then you must use <see cref="ZipEntry.Extract(String,
/// ExtractExistingFileAction)" /> or one of the similar methods.
/// </para>
///
/// <para>
/// Calling this method is equivalent to setting the <see
/// cref="ExtractExistingFile"/> property and then calling <see
/// cref="ExtractAll(String)"/>.
/// </para>
///
/// <para>
/// This method will send verbose output messages to the
/// <see cref="StatusMessageTextWriter"/>, if it is set on the <c>ZipFile</c> instance.
/// </para>
/// </remarks>
///
/// <example>
/// This example extracts all the entries in a zip archive file, to the
/// specified target directory. It does not overwrite any existing files.
/// <code>
/// String TargetDirectory= "c:\\unpack";
/// using(ZipFile zip= ZipFile.Read(ZipFileToExtract))
/// {
/// zip.ExtractAll(TargetDirectory, ExtractExistingFileAction.DontOverwrite);
/// }
/// </code>
///
/// <code lang="VB">
/// Dim TargetDirectory As String = "c:\unpack"
/// Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
/// zip.ExtractAll(TargetDirectory, ExtractExistingFileAction.DontOverwrite)
/// End Using
/// </code>
/// </example>
///
/// <param name="path">
/// The path to which the contents of the zipfile will be extracted.
/// The path can be relative or fully-qualified.
/// </param>
///
/// <param name="extractExistingFile">
/// The action to take if extraction would overwrite an existing file.
/// </param>
/// <seealso cref="ExtractSelectedEntries(String,ExtractExistingFileAction)"/>
public void ExtractAll(string path, ExtractExistingFileAction extractExistingFile)
{
ExtractExistingFile = extractExistingFile;
_InternalExtractAll(path, true);
}
示例12: Extract
public static void Extract(string zipFile, ExtractExistingFileAction action = ExtractExistingFileAction.OverwriteSilently)
{
using (ZipFile zip = ZipFile.Read(zipFile))
{
foreach (ZipEntry e in zip)
{
zip.ExtractAll(e.FileName, action);
}
}
}
示例13: ExtractAll
public static void ExtractAll(ZipFile zip, string destination,
ExtractExistingFileAction extractExitingFileAction = ExtractExistingFileAction.OverwriteSilently)
{
foreach (var entry in zip.Entries) {
if (string.Equals(entry.FileName, "__MACOSX", StringComparison.OrdinalIgnoreCase) ||
string.Equals(entry.FileName, ".DS_Store", StringComparison.OrdinalIgnoreCase))
continue;
entry.Extract (destination, extractExitingFileAction);
}
}
示例14: Extract
/// <summary>
/// Extract the entry to a file in the filesystem, using the specified
/// behavior when extraction would overwrite an existing file.
/// </summary>
///
/// <remarks>
/// <para>
/// See the remarks on the <see cref="LastModified"/> property, for some
/// details about how the last modified time of the file is set after
/// extraction.
/// </para>
/// </remarks>
///
/// <param name="extractExistingFile">
/// The action to take if extraction would overwrite an existing file.
/// </param>
public static void Extract(this ZipEntry zipEntry, ExtractExistingFileAction extractExistingFile)
{
zipEntry.ExtractExistingFile = extractExistingFile;
zipEntry.InternalExtractToBaseDir(".", null);
}
示例15: ExtractWithPassword
/// <summary>
/// Extract the entry to the filesystem, starting at the specified base
/// directory, and using the specified behavior when extraction would
/// overwrite an existing file.
/// </summary>
///
/// <remarks>
/// See the remarks on the <see cref="LastModified"/> property, for some
/// details about how the last modified time of the created file is set.
/// </remarks>
///
/// <param name="baseDirectory">the pathname of the base directory</param>
///
/// <param name="extractExistingFile">The action to take if extraction would
/// overwrite an existing file.</param>
///
/// <param name="password">The Password to use for decrypting the entry.</param>
public static void ExtractWithPassword(this ZipEntry zipEntry, string baseDirectory, ExtractExistingFileAction extractExistingFile, string password)
{
zipEntry.ExtractExistingFile = extractExistingFile;
zipEntry.InternalExtractToBaseDir(baseDirectory, password);
}