【发布时间】:2015-05-15 11:02:08
【问题描述】:
我正在尝试使用 .Net 类 Microsoft.VisualBasic.FileIO.TextFieldParser 读取 csv。我遇到的问题是变量 netArray 的值似乎被设置为单个字符串,而没有将值拆分为单独的数组条目。知道为什么会发生这种情况吗?
int counter, xppArrayLength;
str xppValue;
str arr[];
System.String[] netArray;
System.String[] delimeters = new System.String[1]();
Microsoft.VisualBasic.FileIO.TextFieldParser parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(myPath);
delimeters.SetValue(",",0);
parser.set_Delimiters(delimeters);
parser.set_HasFieldsEnclosedInQuotes(true);
netArray = parser.ReadLine();
while(netArray.get_Length())
{
xppArrayLength = netArray.get_Length();
for(counter = 1; counter <= xppArrayLength; counter++)
{
xppValue = netArray.GetValue(counter-1);
arr[counter] = xppValue;
}
netArray = parser.ReadLine();
} }
【问题讨论】:
-
只是为了确保,您知道 AX 中有 CommaTextIO 类允许您读取和写入 csv 文件吗? (stackoverflow.com/questions/4390940/…)
-
不,我不是。你知道那个类是否能够忽略引号中的逗号吗?
-
是的,它能够做到这一点(另见community.dynamics.com/ax/f/33/p/66618/121484)
标签: .net axapta dynamics-ax-2012