日期:2014-05-20 浏览次数:21077 次
public static List<String[]> ReadTxt(string filePathName) { List<String[]> ls = new List<String[]>(); StreamReader fileReader=new StreamReader(filePathName); string strLine=""; while (strLine != null) { strLine = fileReader.ReadLine(); if (strLine != null && strLine.Length>0) { ls.Add(strLine.Split(',')); //Debug.WriteLine(strLine); } } fileReader.Close(); return ls; }
------解决方案--------------------
stringbuild sb=new stringbuild();
StreamReader fileReader=new StreamReader(filePathName);
string strLine="";
while (strLine != null)
{
strLine = fileReader.ReadLine();
if (strLine != null && strLine.Length>0)
{
string[] Values = strLine .Split(',');
//数据库sql语句
sb.append("insert into table(....)values(values[0],values[1]..)"
}
}
//执行数据库操作
exSQL(sb.tostring());