本文整理汇总了C#中Ionic.Zip.ZipFile.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# ZipFile.ToArray方法的具体用法?C# ZipFile.ToArray怎么用?C# ZipFile.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic.Zip.ZipFile
的用法示例。
在下文中一共展示了ZipFile.ToArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(ZipFile zip, ProgressCallback callback, out bool wasChanged)
{
var entries = zip.ToArray();
wasChanged = false;
for (var index = 0; index < entries.Length; index++)
{
callback(zip, (index + 1), entries.Length);
var entry = entries[index];
foreach (var op in _operations)
{
OperationResult result;
if (entry.IsDirectory)
{
result = op.HandleDirectory(entry, zip);
}
else
{
result = op.HandleFile(entry, zip);
}
if (result == OperationResult.Removed)
{
Console.WriteLine("Removed: {0}", entry.FileName);
wasChanged = true;
break;
}
if (result == OperationResult.Changed)
{
wasChanged = true;
}
}
}
}
示例2: Upload
private void Upload()
{
//get file name
string image = null;
this.Invoke(new MethodInvoker(delegate
{
if (ImageList.SelectedIndex == 0) { CloseOnError("You need to select a version!"); return; }
image = ImageList.Items[ImageList.SelectedIndex] + ".rim";
}));
//connect to brick
try
{
if (!mybrick.Connect()) { throw new NXTNotConnected(); }
}
catch (SocketException)
{ CloseOnError("Brick is busy! Perform a soft reset by turning the brick off for a few seconds."); return; }
catch (Win32Exception)
{ CloseOnError("Brick is busy! Perform a soft reset by turning the brick off for a few seconds."); return; }
catch (NullReferenceException)
{ CloseOnError("Not connected to a brick!"); return; }
catch (Exception ex)
{ CloseOnError(ex.Message); return; }
try
{
//create temporary directory
string temp = "tmp";
if (Directory.Exists(temp)) { Directory.Delete(temp, true); }
Directory.CreateDirectory(temp);
//create vault directory
if (!Directory.Exists(vaultdir)) { Directory.CreateDirectory(vaultdir); }
//download file, if need to
if (vaultfiles != null)
{
System.Net.WebClient webs = new System.Net.WebClient();
webs.DownloadFile("http://ehsandev.com/robotics/images/" + image, vaultdir + image);
}
//load zip
ZipFile zip = new ZipFile(vaultdir + image);
ZipEntry[] files = zip.ToArray();
Progress.Invoke(new MethodInvoker(delegate { Progress.Maximum = files.Length + 2; }));
//keep brick alive
mybrick.link.KeepAlive();
//remove all NXT user files
WipeBrick();
//download files
foreach (ZipEntry file in files)
{
AddProgress(1);
SetStatus("Extracting " + file.FileName + "...");
file.Extract(temp + "/", ExtractExistingFileAction.OverwriteSilently);
SetStatus("Uploading " + file.FileName + "...");
mybrick.UploadFile(temp + "/" + file.FileName, file.FileName);
}
//clean up
Directory.Delete(temp, true);
}
catch (Exception ex)
{
CloseOnError(ex.Message);
return;
}
//return successfully
CloseOnError(null);
}