Skip to content

Instantly share code, notes, and snippets.

@robsmith1776
Last active April 20, 2016 18:31
Show Gist options
  • Save robsmith1776/cf95a63930e338bf52fb41861a72fc20 to your computer and use it in GitHub Desktop.
Save robsmith1776/cf95a63930e338bf52fb41861a72fc20 to your computer and use it in GitHub Desktop.
Function to Write to DataTables
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