![](/img/trans.png)
[英]How to Transforming origin for painteventargs in a c# winform?
[英]How to get “Content Created” of origin property? C# Winform
無需使用該文件。 只需使用內置文檔屬性:
internal DateTime GetContentCreatedDate()
{
Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;
Office.DocumentProperties properties = (Office.DocumentProperties)doc.BuiltInDocumentProperties;
return (DateTime)properties[Word.WdBuiltInProperty.wdPropertyTimeCreated].Value;
}
我已經能夠獲得新的Office文件格式的數據(例如:.docx,.xlsx等)。
新的office文件格式本質上是Zip文件,里面有XML數據。
“創建內容”日期保存在標簽“ dcterms:created
”中的XML文件“ docProps\\core.xml
”中。
一個例子可能是:
using System.IO.Compression;
using System.Xml;
ZipArchive archive = new ZipArchive(file.OpenBinaryStream());
var stream = archive.GetEntry(@"docProps/core.xml").Open();
using (var reader = XmlReader.Create(stream))
{
for (reader.MoveToContent(); reader.Read();)
if (reader.NodeType == XmlNodeType.Element && reader.Name == "dcterms:created")
{
stream.Close();
return DateTime.Parse(reader.ReadElementString());
}
}
我仍然在研究舊的文件格式,但OpenMCDF是那些前進的方式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.