While line trReadLine null.
How to create a tab delimited text file using c#.net. You can then open the file in Microsoft Excel. Appending the DataTable data to Text File in C can be achieved easily by just lopping each row of the DataTable and placing to text file as code shown below. Heres a method that takes data from a DataReader and writes it to a file.
String items lineSplit t. Below is a sample using C to read a tab delimited file. This example creates a sample ASPNET Visual C NET page named ExcelCSaspx.
Here is some sample code that should get you started. You can then open the file in Microsoft Excel. Create File with File Options.
Reading a tab delimited text file into DataTable DataTable records new DataTablerecords. In this article. The Create method has four overloaded forms provide options with a file buffer size file options and file security.
The TextFieldParser object provides a way to easily and efficiently parse structured text files such as logs. In the below code i have created the DataTable with three columns and entered the data. FileCreate name of the file number of bytes buffered for read and write to the file FileStream fs FileCreate fileName 1024.
Why not just output it to a stream and use the Replace function to replace the commas with tabs. Using TextReader tr FileOpenText TabDelimitedFiletxt. Create a new TextFieldParserThe following code creates the TextFieldParser named MyReader and opens the file testtxt.