/**//// <summary>
/// 從文本文件導入
/// </summary>
/// <param name="Filename">文件路徑</param>
/// <param name="dtData">數據</param>
/// <returns>數據集</returns>
public DataTable TxtToDataSet(string Filename, ref DataTable dtData)
...{
DataSet ds = new DataSet();
try
...{
StreamReader sr = new StreamReader(Filename, Encoding.GetEncoding("gb2312"));
//sr.CurrentEncoding.
String line;
DataRow myRow;
while ((line = sr.ReadLine()) != null)
...{
myRow = dtData.NewRow();
string[] strs = line.Split('','');
int i = 0, j = 0, linelength = strs.Length;
foreach (string s in strs)
...{
myRow[j++] = s;
if (j == linelength)
...{
j = 0;
i++;
}
}
dtData.Rows.Add(myRow);
}
//關閉刪除
sr.Close();
File.Delete(Filename);
}
catch (Exception ex)
...{
throw ex;
}
return dtData;
}