惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
V
Visual Studio Blog
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿
Vercel News
Vercel News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
D
DataBreaches.Net
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
大猫的无限游戏
大猫的无限游戏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
The Cloudflare Blog
宝玉的分享
宝玉的分享
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - sumh

用PowerShell批量删除未部署的wsp包 用PowerShell批量收回wsp包 用PowerShell批量部署wsp包 WSS3.0升级到Foundation 2010 PowerShell 操作bcs PowerShell搜索元数据 开发,部署,监视SharePoint 2010的沙盒解决方案 修改MOSS的RTF字段的上传图片功能 高权限的工作流 可重用声明性工作流 站点工作流 工作流事件 可插接式的工作流服务 sharepoint 2010 beta Workflow WF4的新功能 介绍WF4 用Aspx页面做流程表单的一些感想 创建网站集的内容类型 创建Infopath表单数据源的详细步骤图解
用Openxml获取本地文件的扩展信息
sumh · 2011-11-08 · via 博客园 - sumh
 

FileInfo类只能获取文件的基本信息,对于文件的详细信息无法获取,因此获取文件详细信息可以采用两种方式:

一是用shell32shellclass类获取;

二是用Openxml来获取。

第一种比较麻烦在vssharepoint空项目中无法载入,在webapplication里可以正常使用;如果想使用那么需要用dllload导入。

第二种采用openxmlopenxml只能操作office2007以上版本的文档,目前支持wordexcelppt三种。下面以word为例:

用WordprocessingDocument类来操作文档,具体的代码如下:

using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(url, true))

{

    CoreFilePropertiesPart corePart = wordDoc.CoreFilePropertiesPart;

  //获取本地文件的作者

    string creator = corePart.OpenXmlPackage.PackageProperties.Creator;

}