gpt4 book ai didi

c# - 在文档 SP URL 中查找单词

转载 作者:行者123 更新时间:2023-11-30 22:56:14 26 4
gpt4 key购买 nike

我有一个示例代码,如果文档在本地,它可以正常工作,但是如果我指向链接,则立即出错,如何获胜?

using DocumentFormat.OpenXml.Packaging;
using OpenXmlPowerTools;

using (WordprocessingDocument doc = WordprocessingDocument.Open(@"http://sp-test/sites/test/Documents/Base.docx", true))
TextReplacer.SearchAndReplace(wordDoc: doc, search: "Tags", replace: "Test", matchCase: false);

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in DocumentFormat.OpenXml.dll

Additional information: Could not find document

最佳答案

WordprocessingDocument.Open 查找 fileHandleStream 但您提供的 URL 不会感觉。

您首先需要使用 HttpClient 将文件下载为 Stream 然后使用WordprocessingDocument.Open(stream) 相应地

关于c# - 在文档 SP URL 中查找单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54557060/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com