本文整理汇总了C#中Ionic.Zip.ZipFile.Where方法的典型用法代码示例。如果您正苦于以下问题:C# ZipFile.Where方法的具体用法?C# ZipFile.Where怎么用?C# ZipFile.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic.Zip.ZipFile
的用法示例。
在下文中一共展示了ZipFile.Where方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Open
public override void Open(string file)
{
zf = ZipFile.Read (file);
Pages = zf.Where (entry => (!entry.IsDirectory && IsValidImage (entry.FileName)))
.OrderBy (e => e.FileName)
.Select (e => new ZipPage (e)).ToList<Page> ();
}
示例2: UnpackZipByRules
public void UnpackZipByRules(string packagePath, string unpackPath, IEnumerable<IUpdateRule> updateRules)
{
CleanFolder(unpackPath, updateRules);
using (var zip = new ZipFile(packagePath) {UseUnicodeAsNecessary = true}) {
foreach (var file in zip.Where(file => updateRules.SatisfiesForUpdate(file.FileName)))
file.Extract(unpackPath, ExtractExistingFileAction.OverwriteSilently);
}
}
示例3: ParsDate
// Parse string name Folder to Datetime
private DateTime ParsDate(ZipFile zip)
{
var collectionOfFolderNames = zip.Where(z => z.IsDirectory == false).ToList();
// Use primery parametar numberOfCount
string nameFolder = collectionOfFolderNames[numberCound].ToString();
string stringDate = nameFolder.Substring(10, 11);
DateTime date = DateTime.Parse(stringDate);
Console.WriteLine(stringDate);
return date;
}
示例4: Form1_DragDrop
private void Form1_DragDrop(object sender, DragEventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback((state) =>
{
this.Invoke(new Action(() =>
{
this.progressBar.Visible = true;
}));
string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop, false);
foreach (string path in paths)
{
DirectoryInfo temporyDirectory = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), String.Format("osirium-unarchive-{0}", DateTime.UtcNow.Ticks)));
try
{
int index = 0;
int indexWidth = 0;
using (ZipFile zipfile = new ZipFile(path))
{
List<ZipEntry> entries = zipfile.Where(entry => Path.GetExtension(entry.FileName).Equals(".png", StringComparison.InvariantCultureIgnoreCase)).ToList();
this.Invoke(new Action(() =>
{
this.progressBar.Maximum = entries.Count + 1;
}));
indexWidth = entries.Count.ToString().Length;
using (Bitmap resized = new Bitmap(1920, 1080))
{
foreach (ZipEntry entry in entries.ToArray())
{
using (MemoryStream data = new MemoryStream())
{
entry.Extract(data);
data.Seek(0, SeekOrigin.Begin);
using (Image image = Bitmap.FromStream(data))
{
using (Graphics g = Graphics.FromImage(resized))
{
g.Clear(Color.Black);
g.DrawImage(image, new Point((resized.Width - image.Width) / 2, (resized.Height - image.Height) / 2));
}
resized.Save(Path.Combine(temporyDirectory.FullName, String.Format("{0}.png", (index++).ToString(String.Format("D{0}", indexWidth)))), ImageFormat.Png);
}
}
this.Invoke(new Action(() =>
{
this.progressBar.Value = index;
}));
}
using (Graphics g = Graphics.FromImage(resized))
{
g.Clear(Color.Black);
}
resized.Save(Path.Combine(temporyDirectory.FullName, String.Format("{0}.png", (index++).ToString(String.Format("D{0}", indexWidth)))), ImageFormat.Png);
this.Invoke(new Action(() =>
{
this.progressBar.Value = index;
}));
}
}
string target = "output.wmv";
string output = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), target);
string arguments = String.Format("-y -loglevel warning -r 1 -b:v 1800 -i %0{0}d.png {1}", indexWidth, target);
using (Process process = Process.Start(new ProcessStartInfo(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "ffmpeg"), arguments) { WorkingDirectory = temporyDirectory.FullName, CreateNoWindow = true, UseShellExecute = false }))
{
process.WaitForExit();
if (process.ExitCode > 0)
{
throw new SystemException("Failed to generate video");
}
}
if (File.Exists(output))
{
File.Delete(output);
}
File.Copy(Path.Combine(temporyDirectory.FullName, target), output);
}
finally
{
temporyDirectory.Delete(true);
this.Invoke(new Action(() =>
//.........这里部分代码省略.........