本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.ZipInputStream.ReadAllBytes方法的典型用法代码示例。如果您正苦于以下问题:C# ZipInputStream.ReadAllBytes方法的具体用法?C# ZipInputStream.ReadAllBytes怎么用?C# ZipInputStream.ReadAllBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpZipLib.Zip.ZipInputStream
的用法示例。
在下文中一共展示了ZipInputStream.ReadAllBytes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureMtnIsExtracted
public static void EnsureMtnIsExtracted()
{
if (!Directory.Exists(MtnPath)) {
Directory.CreateDirectory(MtnPath);
Directory.CreateDirectory(FrameGrabsPath);
string name = "MtnFrameGrabProvider.mtn.zip";
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
using (var zip = new ZipInputStream(stream)) {
ZipEntry entry;
while ((entry = zip.GetNextEntry()) != null) {
string destination = Path.Combine(MtnPath, entry.Name);
File.WriteAllBytes(destination, zip.ReadAllBytes());
}
}
}
}
示例2: EnsureMtnIsExtracted
public static void EnsureMtnIsExtracted()
{
string name = "MtnFrameGrabProvider.mtn.zip";
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
bool needsToExtractMtn = false;
/*
if (!Directory.Exists(MtnPath)) {
Directory.CreateDirectory(MtnPath);
//Directory.CreateDirectory(FrameGrabsPath);
using (var zip = new ZipInputStream(stream)) {
ZipEntry entry;
while ((entry = zip.GetNextEntry()) != null) {
string destination = Path.Combine(MtnPath, entry.Name);
File.WriteAllBytes(destination, zip.ReadAllBytes());
}
}
} else {
FileVersionInfo mtnVersion = FileVersionInfo.GetVersionInfo(MtnExe);
Logger.ReportInfo("Using mtn version:{0}", mtnVersion.FileVersion);
if (mtnVersion.FileVersion == null)
Logger.ReportInfo("Using a pre-versioning copy of mtn.");
}
*/
if (!Directory.Exists(MtnPath))
{
Directory.CreateDirectory(MtnPath);
needsToExtractMtn = true;
}
else
{
FileVersionInfo mtnVersion = FileVersionInfo.GetVersionInfo(MtnExe);
Logger.ReportInfo("Using mtn version:{0}", mtnVersion.FileVersion);
if (mtnVersion.FileVersion != null)
{
if (mtnVersion.FileVersion.ToString() != includedMtnVersion)
{
Logger.ReportInfo("mtn too old!");
needsToExtractMtn = true;
}
}
else
{
Logger.ReportInfo("Using pre-versioning copy of mtn!");
needsToExtractMtn = true;
}
}
if (needsToExtractMtn)
{
using (var zip = new ZipInputStream(stream))
{
ZipEntry entry;
while ((entry = zip.GetNextEntry()) != null)
{
string destination = Path.Combine(MtnPath, entry.Name);
File.WriteAllBytes(destination, zip.ReadAllBytes());
}
}
}
}
示例3: AcceptFileBundle
/// <summary>
/// Accepts a file bundle containing all data of files.
/// </summary>
/// <param name="data">Binary data.</param>
/// <returns>List of events.</returns>
public List<FileEvent> AcceptFileBundle(byte[] data)
{
using (MemoryStream ms = new MemoryStream(data))
using (ZipInputStream zip = new ZipInputStream(ms))
{
ZipEntry block = zip.GetNextEntry();
var myPatchList = zip.ReadAllBytes().Deserialize<List<FileEvent>>();
while (true)
{
block = zip.GetNextEntry();
if (block == null)
{
break;
}
File.WriteAllBytes(Config.MetaFolderData.File(block.Name), zip.ReadAllBytes());
}
// Append versions
Dictionary<string, FileItem> myFileList = new Dictionary<string, FileItem>();
foreach (var item in VersionList.AllFiles)
{
myFileList[item.Id] = item;
}
foreach (var patch in myPatchList)
{
if (!myFileList.ContainsKey(patch.FileId))
{
myFileList[patch.FileId] = new FileItem(patch.FileId);
VersionList.AllFiles.Add(myFileList[patch.FileId]);
VersionList.SetFileByName(patch.Name, myFileList[patch.FileId]);
}
string oldName = myFileList[patch.FileId].CurrentName;
myFileList[patch.FileId].Merge(patch);
string currentName = myFileList[patch.FileId].CurrentName;
if (oldName != currentName)
{
VersionList.RemoveFileByName(oldName);
VersionList.SetFileByName(patch.Name, myFileList[patch.FileId]);
}
}
return myPatchList;
}
}