本文整理汇总了C#中Ionic.ContainsEntry方法的典型用法代码示例。如果您正苦于以下问题:C# Ionic.ContainsEntry方法的具体用法?C# Ionic.ContainsEntry怎么用?C# Ionic.ContainsEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic
的用法示例。
在下文中一共展示了Ionic.ContainsEntry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFileFormatByZip
private static int GetFileFormatByZip(Ionic.Zip.ZipFile oZipFile)
{
if (oZipFile.ContainsEntry("[Content_Types].xml"))
{
Ionic.Zip.ZipEntry oEntry = oZipFile["[Content_Types].xml"];
using (MemoryStream oMemoryStream = new MemoryStream((int)oEntry.UncompressedSize))
{
oEntry.Extract(oMemoryStream);
oMemoryStream.Position = 0;
string sContent = System.Text.UTF8Encoding.UTF8.GetString(oMemoryStream.GetBuffer(), 0, (int)oMemoryStream.Length);
if (-1 != sContent.IndexOf("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml") ||
-1 != sContent.IndexOf("application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml") ||
-1 != sContent.IndexOf("application/vnd.ms-word.document.macroEnabled.main+xml") ||
-1 != sContent.IndexOf("application/vnd.ms-word.template.macroEnabledTemplate.main+xml"))
return FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
else if (-1 != sContent.IndexOf("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml") ||
-1 != sContent.IndexOf("application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml") ||
-1 != sContent.IndexOf("application/vnd.ms-excel.sheet.macroEnabled.main+xml") ||
-1 != sContent.IndexOf("application/vnd.ms-excel.template.macroEnabled.main+xml"))
return FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
else if (-1 != sContent.IndexOf("application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml") ||
-1 != sContent.IndexOf("application/vnd.openxmlformats-officedocument.presentationml.template.main+xml") ||
-1 != sContent.IndexOf("application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml") ||
-1 != sContent.IndexOf("application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml") ||
-1 != sContent.IndexOf("application/vnd.ms-powerpoint.template.macroEnabled.main+xml"))
return FileFormats.AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
else if (-1 != sContent.IndexOf("application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml"))
return FileFormats.AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX;
}
}
if (oZipFile.ContainsEntry("mimetype"))
{
Ionic.Zip.ZipEntry oEntry = oZipFile["mimetype"];
using (MemoryStream oMemoryStream = new MemoryStream((int)oEntry.UncompressedSize))
{
oEntry.Extract(oMemoryStream);
oMemoryStream.Position = 0;
string sContent = System.Text.ASCIIEncoding.ASCII.GetString(oMemoryStream.GetBuffer(), 0, (int)oMemoryStream.Length);
if (-1 != sContent.IndexOf("application/vnd.oasis.opendocument.text"))
return FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT;
else if (-1 != sContent.IndexOf("application/vnd.oasis.opendocument.spreadsheet"))
return FileFormats.AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
else if (-1 != sContent.IndexOf("application/vnd.oasis.opendocument.presentation"))
return FileFormats.AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP;
else if (-1 != sContent.IndexOf("application/epub+zip"))
return FileFormats.AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB;
}
}
if (oZipFile.ContainsEntry("_rels/.rels"))
{
Ionic.Zip.ZipEntry oEntry = oZipFile["_rels/.rels"];
using (MemoryStream oMemoryStream = new MemoryStream((int)oEntry.UncompressedSize))
{
oEntry.Extract(oMemoryStream);
oMemoryStream.Position = 0;
string sContent = System.Text.ASCIIEncoding.ASCII.GetString(oMemoryStream.GetBuffer(), 0, (int)oMemoryStream.Length);
if (-1 != sContent.IndexOf("http://schemas.microsoft.com/xps/2005/06/fixedrepresentation"))
return FileFormats.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS;
}
}
if (oZipFile.ContainsEntry("_rels/.rels/[0].piece"))
return FileFormats.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS;
if (oZipFile.ContainsEntry("Editor.bin"))
{
Ionic.Zip.ZipEntry oEntry = oZipFile["Editor.bin"];
int nFormat = FileFormats.AVS_OFFICESTUDIO_FILE_UNKNOWN;
using (MemoryStream oMemoryStream = new MemoryStream((int)oEntry.UncompressedSize))
{
oEntry.Extract(oMemoryStream);
oMemoryStream.Position = 0;
int nSignatureLength = 4;
if (oMemoryStream.Length >= nSignatureLength)
{
byte[] aSignature = new byte[nSignatureLength];
oMemoryStream.Read(aSignature, 0, nSignatureLength);
string sSignature = System.Text.ASCIIEncoding.ASCII.GetString(aSignature);
switch (sSignature)
{
case "DOCY": nFormat = FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY; break;
case "XLSY": nFormat = FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY; break;
case "PPTY": nFormat = FileFormats.AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY; break;
}
}
}
if(FileFormats.AVS_OFFICESTUDIO_FILE_UNKNOWN != nFormat)
return nFormat;
}
else if (oZipFile.ContainsEntry("Editor.xml"))
{
return FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_PRESENTATION;
}
else if (oZipFile.ContainsEntry("Editor.svg"))
{
return FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_DRAWING;
}
else if (oZipFile.ContainsEntry("Editor.html.arch"))
{
return FileFormats.AVS_OFFICESTUDIO_FILE_OTHER_OLD_DOCUMENT;
//.........这里部分代码省略.........