Last active
April 20, 2016 18:31
-
-
Save robsmith1776/cf95a63930e338bf52fb41861a72fc20 to your computer and use it in GitHub Desktop.
Function to Write to DataTables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void WriteClickLinks(DataTable dt, string filepath) | |
{ | |
StreamWriter output = new StreamWriter(filepath); | |
StringBuilder sb = new StringBuilder(); | |
using (output) | |
{ | |
foreach (DataColumn col in dt.Columns) | |
{ | |
sb.Append(col.ColumnName + tab); | |
} | |
sb.Length--; | |
sb.Append(Environment.NewLine); | |
foreach (DataRow row in dt.Rows) | |
{ | |
foreach (DataColumn col in dt.Columns) | |
{ | |
sb.Append((row[col.ColumnName].ToString()) + tab); | |
} | |
sb.Length--; | |
sb.Append(Environment.NewLine); | |
} | |
output.Write(sb); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment