以非只读方式打开只读文件并保存/覆盖
我有许多正在转换的 Word 文档。一切都很顺利,直到我得到一个只读文件。在这种情况下,我收到“另存为”提示。
有没有办法以读/写格式打开文件?我应该有管理员权限,所以访问不是问题。
我正在使用 VB.net 打开文件。更具体地说
doc = word.Documents.Open(path, Type.Missing, False, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)
I have a number of word documents I am converting. Everything is going great until I get a file that is read only. In this case I get a Save As prompt.
Is there any way to open the file in read/write format? I should have admin privileges so access isn't an issue.
I'm using VB.net to open the files. More specifically
doc = word.Documents.Open(path, Type.Missing, False, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要打开只读文件,您需要将该属性设置为 false:
这是一个示例,但我确信它适用于 Word 文件。
编辑:
VB.NET 等效项:
To open a read-only file you need to set that attribute to false:
This was an example but I'm sure it will work with word files.
EDIT:
VB.NET equivalent:
在打开文件之前,请使用 FileInfo 类检查其属性。
如果 Attributes 属性包含 FileAttributes.ReadOnly,请更改它,文件将不再是只读的。
Before you open the file, check its Attributes with a FileInfo class.
If the Attributes property contains FileAttributes.ReadOnly, change it and the file will no longer be read-only.