请问如何从文本文件中读出各类不同类型的数据?急等,求救
我有个文本文件,格式大概为:
String double double
n001 2.23 5.65
n002 12.8 87.1
... ... ...
请问怎样才可以将数据一行一行的读出来?并传唤为数据相应的结构,第一个未string,剩下的是double?
[解决办法]
先用StreamReader读到一个String中,然后用SubString截取即可
[解决办法]
FileStreamfile= new FileStream(@ "D:\Solution\WindowsApplication1\aa.txt ", FileMode.Open);
string strText= String.Empty;
using (StreamReader strReader= new StreamReader(file, Encoding.UTF8))
{
strText= strReader.ReadToEnd();
}
file.Close();
string[] strList;
if (strText.Length > 0)
{
strText= strText.Replace( "\r\n ", ", ");
strList= strText.Split( ', ');
}