当前位置: 首页>>代码示例>>C#>>正文


C# Ionic.ContainsEntry方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:TangramINC,项目名称:DocumentServer,代码行数:101,代码来源:FileConverterUtils2.cs


注:本文中的Ionic.ContainsEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。