The following two scripts do not throw any exceptions when executed, but they do not generate a DOCX file. Why?
// script "csRtCo_spire.doc.cs"
/*/ role exeProgram; outputPath %folders.Workspace%\exe\csRtCo_spire.doc; c CsScript.cs; /*/ //.
script.setup(trayIcon: true, sleepExit: true);
//..
print.clear();
string code = """
using Spire.Doc;
using System;
string sDir = @"C:\Users\Administrator\Desktop";
string sTxt = "hello world!";
string sName = "hello.docx";
newDoc(sDir, sTxt, sName);
void newDoc(string sDir, string sTxt, string sName)
{
Environment.CurrentDirectory = sDir;
var doc = new Document();
var section = doc.AddSection();
var paragraph = section.AddParagraph();
paragraph.AppendText(sTxt);
doc.SaveToFile(sName, FileFormat.Docx2016);
}
""";
var c = CsScript.Compile(code);
if (c == null) return;
c.Run();// script "csRtCo_spire.doc2.cs"
/*/ role exeProgram; outputPath %folders.Workspace%\exe\csRtCo_spire.doc2; c CsScript.cs; /*/ //.
script.setup(trayIcon: true, sleepExit: true);
//..
print.clear();
string code = """
using Spire.Doc;
using System;
string sDir = @"C:\Users\Administrator\Desktop";
string sTxt = "hello world!";
string sName = "hello.docx";
newDoc(sDir, sTxt, sName);
void newDoc(string sDir, string sTxt, string sName)
{
Environment.CurrentDirectory = sDir;
var doc = new Document();
var section = doc.AddSection();
var paragraph = section.AddParagraph();
paragraph.AppendText(sTxt);
doc.SaveToFile(sName, FileFormat.Docx2016);
}
""";
var errors = new List<string>();
var c = CsScript.Compile(code, r: new[] { @"D:\RPA\spire\10.5.0\NET9.0\Spire.Doc.dll" }, errors: errors);
if (c == null) {
Console.WriteLine("Failed to compile:");
foreach (var error in errors) {
Console.WriteLine(error);
}
return;
}
c.Run();