AX 2009 文件读写
AX 文件内容的读写
X++ 这方面使用的是.net Framework,读取文件时,要权限放行。
以下代码,会看到可爱的System.IO.SteamReader。如此熟悉,感动ing。。。
static void readJob(Args _args)
{
System.IO.StreamReader m_streader;
InteropPermission m_Perm = new InteropPermission(InteropKind::ClrInterop);
Notes m_Notes;
m_Perm.assert();
m_streader = new System.IO.StreamReader(@"C:\ms\n01yan_100.copy");
while(int642int(m_streader.Peek())>0)
{
m_Notes += m_streader.ReadToEnd();
}
m_streader.Close();
m_streader.Dispose();
CodeAccessPermission::revertAssert();
info(m_Notes);
// pause;
}
{
System.IO.StreamReader m_streader;
InteropPermission m_Perm = new InteropPermission(InteropKind::ClrInterop);
Notes m_Notes;
m_Perm.assert();
m_streader = new System.IO.StreamReader(@"C:\ms\n01yan_100.copy");
while(int642int(m_streader.Peek())>0)
{
m_Notes += m_streader.ReadToEnd();
}
m_streader.Close();
m_streader.Dispose();
CodeAccessPermission::revertAssert();
info(m_Notes);
// pause;
}
写入
static void StreamWriter(Args _args)
{
System.IO.StreamWriter sw;
InteropPermission perm = new InteropPermission(InteropKind::ClrInterop);
SalesTable st;
;
perm.assert();
sw = new System.IO.StreamWriter(@"C:\test.txt");
while select st
{
sw.WriteLine(st.SalesId);
sw.WriteLine(st.CustAccount + " " + Date2str(st.DeliveryDate,321,2,3,2,3,4));
}
sw.Flush();
sw.Close();
sw.Dispose();
CodeAccessPermission::revertAssert();}
{
System.IO.StreamWriter sw;
InteropPermission perm = new InteropPermission(InteropKind::ClrInterop);
SalesTable st;
;
perm.assert();
sw = new System.IO.StreamWriter(@"C:\test.txt");
while select st
{
sw.WriteLine(st.SalesId);
sw.WriteLine(st.CustAccount + " " + Date2str(st.DeliveryDate,321,2,3,2,3,4));
}
sw.Flush();
sw.Close();
sw.Dispose();
CodeAccessPermission::revertAssert();}
作者:Kurodo
出处:http://Kurodo.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://Kurodo.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。