C# 或 CMD:删除 Word 文件元数据

发布于 2024-10-03 08:04:34 字数 141 浏览 0 评论 0原文

有没有办法使用 C# 或 Windows 批处理命令以编程方式删除 MS Word 文件或图像文件的元数据信息?

手动删除这些信息的方法是在 Windows 资源管理器中右键单击文件,然后选择“属性”>“详细信息”>“删除属性和个人信息”。

Is there a way to remove the metadata information of MS Word files or Image files programmatically using C# or a Windows batch command?

The manual way to remove those information is to right click a file in the windows explorer and selecting 'Properties'>'Details'>'Remove Properties and Personal Information'.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不醒的梦 2024-10-10 08:04:34

这并不容易,至少不容易得到全部。

您可以查看 Litera(以前称为 Softwise)的名为 Metadact 的元数据删除包。

市场上还有其他几种。

如果您想自己做,首先您需要决定什么是“元数据”。

有些可以使用 Word 对象模型(C# 或 VB 的互操作)轻松实现。

有些无法通过 Word 访问,因此您需要使用结构化存储 API 来获取它(就像最后 10 位作者一样)。

如果您谈论的是 DOCX 文件,则可以使用 OpenXML SDK 获取文件内的所有包。然后使用 XML 导航并编辑掉您不需要的部分。

不过,按照这种方式,删除文档内容中的“元数据”要困难得多,因为您必须处理内部 Word 结构(如 RUN),并更改跟踪内容。

It ain't easy, at least not to get it all.

You might look at the metadata removal package called Metadact by Litera (formerly Softwise).

There are several others out on the market too.

If you want to do it yourself, first, you'll need to decide on what you consider "metadata".

Some is pretty easy to get to using the Word Object Model (Interop from C# or VB).

Some can't be accessed via Word, so you'll need to use the Structured Storage API to get at it (Like last 10 authors).

If you're talking about DOCX files, you can use the OpenXML SDK to get at all the packages inside the file. then use XML to navigate and edit out the bits you don't want.

Going that way, though, it's MUCH harder to remove "metadata" in the content of the document, because you'll have to deal with internal Word structures like RUNs, and change tracking stuff.

や三分注定 2024-10-10 08:04:34

谢谢!
我想我找到了删除(或添加)元信息到办公文档的方法。这里有一篇 Microsoft 文章:Dsofile.dll 文件可让您编辑 Office 文档属性未安装 Office (KB 224351)

Dsofile.dll 示例文件是一个进程内 ActiveX 组件,用于
使用 Microsoft Visual Basic .NET 或 Microsoft .NET 的程序员
框架。您可以在自定义应用程序中使用它来读取和
编辑与 Microsoft 关联的 OLE 文档属性
Office 文件,例如以下内容:

  • Microsoft Excel 工作簿
  • Microsoft PowerPoint 演示文稿
  • Microsoft Word 文档 Microsoft
  • 项目项目 Microsoft Visio 绘图
  • 以 OLE 结构化存储格式保存的其他文件

Dsofile.dll 示例文件是
用 Microsoft Visual C++ 编写。 Dsofile.dll 示例文件
演示如何使用OLE32 IPropertyStorage接口访问
OLE 结构化存储文件的扩展属性。组件
将数据转换为自动化友好的数据类型,以便于使用
高级编程语言,例如 Visual Basic 6.0、Visual
基础 .NET 和 C#。 Dsofile.dll 示例文件包含完整的
源代码并包括用 Visual Basic 6.0 编写的示例客户端
和 Visual Basic .NET 2003 (7.1)。

Thanks!
I think I found way to remove (or add) meta information to office documents. There is a Microsoft article here: The Dsofile.dll files lets you edit Office document properties when you do not have Office installed (KB 224351)

The Dsofile.dll sample file is an in-process ActiveX component for
programmers that use Microsoft Visual Basic .NET or the Microsoft .NET
Framework. You can use this in your custom applications to read and to
edit the OLE document properties that are associated with Microsoft
Office files, such as the following:

  • Microsoft Excel workbooks
  • Microsoft PowerPoint presentations
  • Microsoft Word documents Microsoft
  • Project projects Microsoft Visio drawings
  • Other files that are saved in the OLE Structured Storage format

The Dsofile.dll sample file is
written in Microsoft Visual C++. The Dsofile.dll sample file
demonstrates how to use the OLE32 IPropertyStorage interface to access
the extended properties of OLE structured storage files. The component
converts the data to Automation friendly data types for easier use by
high level programming languages such as Visual Basic 6.0, Visual
Basic .NET, and C#. The Dsofile.dll sample file is given with full
source code and includes sample clients written in Visual Basic 6.0
and Visual Basic .NET 2003 (7.1).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文