本文整理汇总了C#中Ionic.Zip.ZipFile.RemoveSelectedEntries方法的典型用法代码示例。如果您正苦于以下问题:C# ZipFile.RemoveSelectedEntries方法的具体用法?C# ZipFile.RemoveSelectedEntries怎么用?C# ZipFile.RemoveSelectedEntries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic.Zip.ZipFile
的用法示例。
在下文中一共展示了ZipFile.RemoveSelectedEntries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
private static void Save(string fileName, BundleMod mod)
{
//Add .pdmod at end if it's missing
if (!fileName.Contains(".pdmod")) fileName += ".pdmod";
fileName = Path.GetInvalidFileNameChars().Aggregate(fileName, (current, c) => current.Replace(c.ToString(), ""));
BundleMod modToZip = mod;
Dictionary<string, string> filesToZip = new Dictionary<string, string>();
int dupesCount = 1;
foreach (BundleRewriteItem bundleItem in modToZip.ItemQueue)
{
if (bundleItem.ReplacementFile == null)
{
continue;
}
// if (Path.IsPathRooted(bundleItem.ReplacementFile))
// {
if (filesToZip.Values.Contains(Path.GetFileName(bundleItem.ReplacementFile)))
{
filesToZip.Add(bundleItem.ReplacementFile, Path.GetFileNameWithoutExtension(bundleItem.ReplacementFile) + "_" + dupesCount + Path.GetExtension(bundleItem.ReplacementFile));
bundleItem.ReplacementFile = Path.GetFileNameWithoutExtension(bundleItem.ReplacementFile) + "_" + dupesCount + Path.GetExtension(bundleItem.ReplacementFile);
Console.WriteLine(Path.GetFileName(bundleItem.ReplacementFile) + " - " + dupesCount);
dupesCount++;
}
else
{
filesToZip.Add(bundleItem.ReplacementFile, Path.GetFileName(bundleItem.ReplacementFile));
bundleItem.ReplacementFile = Path.GetFileName(bundleItem.ReplacementFile);
}
// }
}
string modjson = BundleMod.Serialize(modToZip);
using (var zip = new ZipFile(fileName))
{
zip.Password = "0$45'5))66S2ixF51a<6}L2UK";
zip.Encryption = EncryptionAlgorithm.WinZipAes256;
zip.RemoveSelectedEntries("*");
foreach (KeyValuePair<string, string> kp in filesToZip)
{
zip.AddEntry(Path.GetFileName(kp.Value), new FileStream(kp.Key, FileMode.Open, FileAccess.Read));
}
zip.AddEntry("pdmod.json", Encoding.UTF8.GetBytes(modjson));
zip.Save();
}
}
示例2: FixMetaInf
public void FixMetaInf()
{
using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(mcFile)) {
zip.RemoveSelectedEntries("META-INF/*.*");
zip.Save();
}
}
示例3: CreateModButtonClick
/// <summary>
/// The create mod button_ click.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
private void CreateModButtonClick(object sender, EventArgs e)
{
//MessageBox.Show("Mod creaton was disabled for this version of Bundle Modder.");
//return;
if (this.newMod.ItemQueue.Count < 1)
{
MessageBox.Show("You must add at least one replacement file before creating a modification package.");
return;
}
if (this.ModNameEdit.TextLength <= 0 || this.ModAuthorEdit.TextLength <= 0)
{
MessageBox.Show("You must enter a name and author for this modification package.");
return;
}
if (this.SpecificVersion.Text == null)
{
this.SpecificVersion.SelectedIndex = 0;
}
this.newMod.Author = this.ModAuthorEdit.Text;
this.newMod.Description = this.ModDescriptionEdit.Text;
this.newMod.Name = this.ModNameEdit.Text;
this.newMod.Version = Convert.ToDouble(this.SpecificVersion.Text, CultureInfo.InvariantCulture);
BundleMod modToZip = BundleMod.Deserialize(BundleMod.Serialize(this.newMod));
Dictionary<string, string> filesToZip = new Dictionary<string, string>();
string replacementPath = "";
foreach (BundleRewriteItem bundleItem in modToZip.ItemQueue)
{
if (bundleItem.ReplacementFile == null)
{
continue;
}
if (Path.IsPathRooted(bundleItem.ReplacementFile))
{
replacementPath = bundleItem.getBundleEntryPath().ToString();
if (Path.GetExtension(bundleItem.ReplacementFile).Equals(".script"))
{
replacementPath = Path.ChangeExtension(replacementPath, "script");
}
int i = 0;
while (filesToZip.Values.Contains(replacementPath + (i == 0 ? "" : i.ToString())))
{
i++;
}
replacementPath = replacementPath + (i == 0 ? "" : i.ToString());
//filesToZip.Add(bundleItem.SourceFile, replacementPath);
if (filesToZip.ContainsKey(replacementPath))
{
DialogResult dialogResult = MessageBox.Show("The current replacement path has already been used '" + replacementPath + "' \n\n Would you like to continue and skip this entry? (Pressing no will stop mod creation)", "Entry already Present", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
}
else if (dialogResult == DialogResult.No)
{
return;
}
}
else
{
filesToZip.Add(replacementPath, bundleItem.ReplacementFile);
}
bundleItem.ReplacementFile = replacementPath;
bundleItem.SourceFile = null;
}
}
string modjson = BundleMod.Serialize(modToZip);
var saveDialog = new SaveFileDialog();
saveDialog.Filter = "PAYDAY Mods(*.pdmod)|*.pdmod";
saveDialog.FileName = this.newMod.Name + ".pdmod";
if (saveDialog.ShowDialog() != DialogResult.OK)
{
return;
}
using (var zip = new ZipFile(saveDialog.FileName))
{
if (StaticStorage.settings.AlwaysPasswordProtect)
{
zip.Password = "0$45'5))66S2ixF51a<6}L2UK";
zip.Encryption = EncryptionAlgorithm.WinZipAes256;
}
zip.RemoveSelectedEntries("*");
//.........这里部分代码省略.........