本文整理汇总了C#中Ionic.Zip.ZipEntry.OpenReader方法的典型用法代码示例。如果您正苦于以下问题:C# ZipEntry.OpenReader方法的具体用法?C# ZipEntry.OpenReader怎么用?C# ZipEntry.OpenReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic.Zip.ZipEntry
的用法示例。
在下文中一共展示了ZipEntry.OpenReader方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContentSection
public ContentSection(ZipEntry entry)
{
Id = Path.GetFileNameWithoutExtension(entry.FileName);
ArchivePath = entry.FileName;
using (Stream s = entry.OpenReader())
{
using (StreamReader sr = new StreamReader(s))
{
Content = sr.ReadToEnd();
}
}
}
示例2: OpfMetadataFile
public OpfMetadataFile(ZipEntry file, string password)
{
try
{
using (Stream s = (String.IsNullOrEmpty(password) ? file.OpenReader() : file.OpenReader(password)))
{
using (StreamReader sr = new StreamReader(s))
{
try
{
content = XDocument.Parse(sr.ReadToEnd());
}
catch (Exception ex)
{
throw new MetadataParseException(ex, "Nie można było otworzyć pliku z metadanymi. Może to być spowodowane uszkodzeniem jego struktury XMLowej, niewłaściwym kodowaniem, albo brakiem dostępu.");
}
}
}
}
catch (Exception ex)
{
throw new EpubFileException(ex, "Błąd w rozpakowywaniu pliku ePub. Może to być spowodowane uszkodzeniem pliku, brakiem plików z metadanymi bądź brakiem dostępu.");
}
}
示例3: GetStringFile
public static string GetStringFile(ZipEntry zipEntry)
{
if (zipEntry != null)
{
using (var stream = zipEntry.OpenReader())
{
using (StreamReader sr = new StreamReader(stream, KPGenericUtil.GetDefaultEncoding()))
{
string fileString = sr.ReadToEnd();
return fileString;
}
}
}
return String.Empty;
}
示例4: Save
private static void Save(ZipEntry entry, string outputFilePath)
{
using (var input = entry.OpenReader())
{
var folderPath = Path.GetDirectoryName(outputFilePath);
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
using (Stream output = File.OpenWrite(outputFilePath))
{
CopyStream(input, output);
}
}
}
示例5: IterateOverCSVZipEntry
protected void IterateOverCSVZipEntry(ZipEntry entry, Func<GenericParserAdapter, bool> func)
{
using (var reader = new StreamReader(entry.OpenReader())) {
using (var parser = new GenericParserAdapter(reader)) {
parser.ColumnDelimiter = ',';
parser.FirstRowHasHeader = true;
parser.TextQualifier = '\"';
parser.FirstRowSetsExpectedColumnCount = true;
while (parser.Read()) {
if (func != null) {
if (!func(parser)) {
return;
}
}
}
}
}
}
示例6: Input2String
/// <summary>
/// Provide Entry Content
/// </summary>
/// <param name="ze"></param>
/// <returns></returns>
private List<string> Input2String(ZipEntry ze)
{
List<string> result = new List<string>();
try
{
using (var s = ze.OpenReader())
{
var sr = new StreamReader(s);
string line = sr.ReadLine();
while (line != null)
{
result.Add(line);
line = sr.ReadLine();
}
}
//using (var ms = new MemoryStream())
//{
// int n;
// var buffer = new byte[1024];
// while ((n = s.Read(buffer, 0, buffer.Length)) > 0)
// ms.Write(buffer, 0, n);
// ms.Seek(0, SeekOrigin.Begin);
// var sr = new StreamReader(ms);
// result = sr.ReadToEnd();
// sr.Close();
// sr.Dispose();
//}
}
catch (Exception ex)
{ throw ex; }
return result;
}
示例7: ExtractTestStepIndex
private void ExtractTestStepIndex(ZipEntry entry)
{
using (var reader = new StreamReader(entry.OpenReader()))
{
var text = reader.ReadToEnd();
TestStepIndex = int.Parse(text);
}
}
示例8: ErrorLog
static ErrorLog ErrorLog(ZipEntry entry)
{
using(var reader = entry.OpenReader())
using(var stream = new StreamReader(reader))
return (ErrorLog) serializer.Deserialize(stream);
}
示例9: ExtractEnvironmentName
private void ExtractEnvironmentName(ZipEntry entry)
{
using (var reader = new StreamReader(entry.OpenReader()))
{
Environment = reader.ReadToEnd();
}
}
示例10: UpdateXmlEntity
private static void UpdateXmlEntity(ZipEntry entry, string selector, Action<XElement> update, ZipFile zip, IXmlNamespaceResolver nsResolver)
{
var output = new MemoryStream();
using (var entryStream = entry.OpenReader())
{
var xml = XDocument.Load(entryStream);
update(xml.XPathSelectElement(selector, nsResolver));
xml.Save(output);
}
zip.UpdateEntry(entry.FileName, output.GetBuffer());
zip.Save();
}
示例11: UpdateCsFiles
private static void UpdateCsFiles(ZipEntry entry, string slideId, ZipFile zip)
{
string code;
using (var entryStream = entry.OpenReader())
{
code = new StreamReader(entryStream).ReadToEnd();
}
code = Regex.Replace(code, "(?<=\\[Slide\\(\".*\",\\s*\").+(?=\"\\)\\])", slideId);
zip.UpdateEntry(entry.FileName, code, Encoding.UTF8);
zip.Save();
}
示例12: AddModFile
public void AddModFile(ZipEntry ModFile)
{
AddModFile(ModFile.OpenReader(), ModFile.FileName);
}
示例13: CopyFileInZipToLocation
private void CopyFileInZipToLocation(ZipEntry entry)
{
string targetFilePath = CreateTargetPathForZipEntry(entry);
if (File.Exists(targetFilePath))
return;
using (var stream = entry.OpenReader())
using (var memoryStream = new MemoryStream())
{
stream.CopyTo(memoryStream);
File.WriteAllBytes(targetFilePath, memoryStream.ToArray());
}
}