Q:

Saving DataTable to Text File Produces Blank Text File

I'm using the following code to write data from datatable to a text file. 
The text file is created,but its blank. 
StreamWriter sw = File. CreateText("myfile.txt");
foreach (DataRow row in filteredResults. Rows)
{
sw. WriteLine(row["columnname"].ToString());
}

What am i doing wrong? 

A:

You need to use using around your code, like this:
  using (StreamWriter sw = File. CreateText(@"..\..\myfile.txt"))
  {
       foreach (DataRow row in dt. Rows)
       {
           sw. WriteLine(row["QueueId"].ToString());
       }
  }

That should resolve your issue.  Also to be absolutely sure that data has been send to the storage facility you could call Flush() method on your stream at the end of the using block.