AX2012 向TXT文件写数据
public static void saveLog(str _msg) { TextIo textIo; Filename name; System.DateTime time; str timeStr; FileIOPermission fioPermission; #File ; time = System.DateTime::get_Now(); timeStr = time.ToString("yyyy-MM-dd HH-mm-ss"); name = strFmt(@"%1\log\log %2.txt", parameter.FilePathStr, timeStr); fioPermission = new FileIOPermission(name, "RW"); fioPermission.assert(); //检查是否存在log文件夹,如果不存在,则创建 if (!isRunningOnServer() && !WinApi::pathExists(parameter.FilePathStr + "\\log")) { System.IO.Directory::CreateDirectory(parameter.FilePathStr + "\\log"); //创建该文件夹 } textIo = new TextIo(name, #IO_WRITE); textIo.write(_msg); textIo = null; CodeAccessPermission::revertAssert(); }