请问:
怎么对dat文件进行读写操作(非二进制文件)。
谢谢。例如:1 120100014 1次/项 1.00 4.0000 4209 2013
1 120400006-3 1组 5.00 1.0000 4209 2013
1 00009046 1.00 20.0000 4209 2013
1 00004147 1次 1.00 10.0000 4209 2013
1 110900001-3 1天 -1.00 20.0000 4209 2013
1 110200005 1天 -1.00 4.0000 4209 2013 写入操作数据来源于数据库。
怎么对dat文件进行读写操作(非二进制文件)。
谢谢。例如:1 120100014 1次/项 1.00 4.0000 4209 2013
1 120400006-3 1组 5.00 1.0000 4209 2013
1 00009046 1.00 20.0000 4209 2013
1 00004147 1次 1.00 10.0000 4209 2013
1 110900001-3 1天 -1.00 20.0000 4209 2013
1 110200005 1天 -1.00 4.0000 4209 2013 写入操作数据来源于数据库。
怎么对dat文件进行读写操作(非二进制文件)。
谢谢。例如:1 120100014 1次/项 1.00 4.0000 4209 2013
1 120400006-3 1组 5.00 1.0000 4209 2013
1 00009046 1.00 20.0000 4209 2013
1 00004147 1次 1.00 10.0000 4209 2013
1 110900001-3 1天 -1.00 20.0000 4209 2013
1 110200005 1天 -1.00 4.0000 4209 2013 写入操作数据来源于数据库。
//文件流
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read,
FileShare.None, 1, true);
//读取流
StreamReader sr = new StreamReader(fs);
//按行读取
string readLine = sr.ReadLine();
while (readLine ! = 0 )
{
//你的操作
readLine = sr.ReadLine();
}
{
List<Object[]> ls = new List<Object[]>();
StreamReader fileReader = new StreamReader(filePathName, Encoding.Default);
string line = "";
while (line != null)
{
line = fileReader.ReadLine();
if (String.IsNullOrEmpty(line))
continue;
String[] array = line.Split(' '); //用空格分割行数据
ls.Add(array);
}
fileReader.Close();
return ls;
}