码迷,mamicode.com
首页 > 其他好文 > 详细

使用open xml 判断sharepoint文档是否损坏

时间:2016-11-15 19:58:15      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:int   type   cat   str   XML   als   path   ted   poi   

方式:

使用 open xml的open 方法直接对文件进行打开操作,可以根据出现的异常类型进行判断,

下面的方式省略这部分(默认只要打不开就认为文件有问题)

            bool isCorrupted = false;
            // Insert some text into the body, this would cause Schema Error
            try
            {
                using (WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(stream, true)) //(filepath, true) stream type is Stream
                {
                }
            }
            catch
            {
                isCorrupted = true;
            }

使用open xml 判断sharepoint文档是否损坏

标签:int   type   cat   str   XML   als   path   ted   poi   

原文地址:http://www.cnblogs.com/zchblog/p/6066783.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!