[英]Writing to docx using xceed.words.net.docx, works when run in VS, writes a line per page when run as built 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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.