write text file into dataset

  • Thread starter Thread starter WebSim via .NET 247
  • Start date Start date
W

WebSim via .NET 247

Hi,
I want to read a text file, and then write it into dataset. Is it possible?
or Is there any solution that read text file into DB?
 
Hi WebSim,

Just store the text file as a byte[].

DataSet set = new DataSet();
set.Tables.Add(new DataTable());
set.Tables[0].Columns.Add(new DataColumn("col", typeof(byte[])));

FileStream fs = File.OpenRead("any.file");
byte[] b = new byte[fs.Length];
fs.Read(b, 0, (int)fs.Length);
fs.Close();

DataRow dr = set.Tables[0].NewRow();
dr[0] = b;
set.Tables[0].Rows.Add(dr);
 
Back
Top