c# - StreamReader with tab delimited text file -
i have similar requirement post... populate gridview @ runtime using textfile
where want read text file streamreader
, populate datatable
info in file, i'm not sure how implement split()
tab.
could point me in right direction, please?
you can seek this:
datatable table = new datatable(); table.columns.add("col1"); table.columns.add("col2"); table.columns.add("col3"); var lines = file.readalllines(@"data.txt").tolist(); lines.foreach(line => table.rows.add(line.split((char)9)));
i presumed rows delimited newline (if that's case readalllines
method can used). number 9 ascii value horizontal tab character , used splitting line. foreach
method can used on generic lists, there instead of foreach
loop.
c# asp.net split streamreader tab-delimited-text
No comments:
Post a Comment