[英]AX2012 Print txt file to printer
從AX2012 R3將文本文件打印到特定打印機時,我遇到問題。 這是我的資料來源:
public void printToPrinter(str _text, str printerName)
{
#File
System.Diagnostics.ProcessStartInfo processInfo;
System.Diagnostics.Process process;
System.Exception interopException;
TextIo textIo;
PrintPathTable printPath = PrintPathTable::find();
str fileName, arguments;
FileIoPermission perm;
try
{
// Get the path and name.
fileName = this.getGuid();
fileName = strFmt(@'%1%2',printPath.PrintPath, fileName);
// Assert permission.
perm = new FileIoPermission(fileName,'RW');
perm.assert();
// Open file for writing.
textIo = new TextIo(fileName, #IO_WRITE);
textIo.write(_text);
// Close the file.
textIo = null;
arguments = '\"' + printerName + '\"';
process = new System.Diagnostics.Process();
processInfo = process.get_StartInfo();
processInfo.set_Verb('printto');
processInfo.set_UseShellExecute(true);
processInfo.set_Arguments(arguments);
processInfo.set_FileName(fileName);
processInfo.set_WindowStyle(System.Diagnostics.ProcessWindowStyle::Hidden);
process.set_StartInfo(processInfo);
process.Start();
// revert asserted permissions
CodeAccessPermission::revertAssert();
}
catch(Exception::CLRError)
{
interopException = CLRInterop::getLastException();
while (!CLRInterop::isNull(interopException.get_InnerException()))
{
interopException = interopException.get_InnerException();
}
error(strFmt('Fehler Druck "%1", "%2"', fileName, CLRInterop::getAnyTypeForObject(interopException.get_Message())));
}
}
在process.Start()
每次都收到錯誤消息:指定的文件未分配給應用程序。
我還檢查了擴展名.txt在AOS上的分配。 該方法在服務器上運行。
我根據以下示例進行了操作:
好吧,我欺騙了自己,
我已經通過AOS上的個人登錄檢查了文件分配。 這里的分配是正確的,但是源是由AOS服務用戶執行的。 未為AOS服務用戶設置分配。 可能是通過安裝第三方軟件。根據.txt在記事本中的分配,它可以按需運行。
感謝所有考慮過的人
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.