c# - 使用 xceed.words.net.docx 写入 docx,在 VS 中运行时有效,在作为内置 exe 运行时每页写入一行
问题描述
我已经使用了一段时间,它总是工作得很好。项目在运行时写入 docx 日志文件。我最近对它写入日志的路径进行了修改,以供其他人使用。从那时起,当我将它作为构建的 exe 运行时,它每页写一行。但是当我尝试解决问题时,我无法在 VS 中重新创建它运行它。从那里它像往常一样工作。
有任何想法吗?有人可以指出我的方向吗?
public static void WritetoLogFile(string logUpdate)
{
DateTime now = DateTime.Now;
string logDate = now.ToString("MM-dd");
string folderNameDate = now.ToString("MM_dd_yyyy");
string folderName = folderNameDate + "_Logs";
string stateFolder = " ";
System.IO.Directory.CreateDirectory(Crawlspace.networkSharePath + "//" + folderName);
string logName = logDate + "_" + Crawlspace.browser + "_" + Crawlspace.computerName + "_" + Crawlspace.SuiteTable + ".docx";
Crawlspace.LogFileName = logName;
System.IO.Directory.CreateDirectory(Crawlspace.networkSharePath + folderName + "//" + stateFolder);
Crawlspace.LogFile = Crawlspace.networkSharePath + folderName + "//" + stateFolder + "//" + logName;
if (System.IO.File.Exists(Crawlspace.LogFile))
{
using (DocX document = DocX.Load(Crawlspace.LogFile))
{
Paragraph par1 = document.InsertParagraph();
par1.Append(logUpdate);
par1.Font("Courier New");
par1.FontSize(8);
document.Save();
}
}
else
{
using (DocX document = DocX.Create(Crawlspace.LogFile))
{
Paragraph par1 = document.InsertParagraph();
par1.Append(logUpdate);
par1.Font("Courier New");
par1.FontSize(8);
document.Save();
}
}
}
解决方案
解决:
我在 nuget 管理器中检查了 xceed.words.net.docx dll,发现有更新。更新到最新并修改了我的 using 语句以反映更新,它现在正在工作......
using Image = Xceed.Document.NET.Image;
using Paragraph = Xceed.Document.NET.Paragraph;
using Picture = Xceed.Document.NET.Picture;
推荐阅读
- c++ - 更改凭据提供程序 GUID 以进行部署的过程
- python - 从 HTML、CSS 和 JavaScript 中获取干净的字符串
- c# - C# ComboBox 绘制冻结
- css - 找到多个答案时,QnA Maker 自定义响应卡
- java - Eclipse 错误:“此编译单元不在 Java 项目的构建路径上”
- c# - 按请求类型动态调用处理器
- reactjs - 如何为 React js 中的函数编写单元测试?
- excel - 根据 excel 中的相似时间/日期对齐列和相关数据
- android - 使用 Robolectric 和 Mockito 模拟 PackageManager
- swift - 通过在 Swift 中使用高阶函数,这是否会影响 Big O 时间或空间复杂度以提高效率?