首页 > 其他 > 详细

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

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

方式:

使用 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文档是否损坏

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!