Lordlebu
Lordlebu

Reputation: 429

WriteLine not printing all the text

I am working on a c# program that is extracting useful data to a flat file.

The data in the source is in this format :


Subject: Daily Alarm

Reach: Global

type: weekly
date: 04/05/2012 16.03.03
amount: 388

type: weekly
date: 04/05/2012 16.03.03
amount: 567


The output should contain these as two rows:


Daily Alarm|Global|weekly|05042012160303|388
Daily Alarm|Global|weekly|05042012160303|567

I am done with the coding and Console.WriteLine is printing the required output

But when I use

System.IO.StreamWriter output = new System.IO.StreamWriter("D:\\SHARPE\\multirow\\destination.txt");

output.WriteLine is yielding a result like this


Daily Alarm|Global|weekly|05042012160303|388
Daily Alarm|Globa

Thanks in Advance

Upvotes: 0

Views: 450

Answers (1)

Avitus
Avitus

Reputation: 15958

Are you calling StreamWriter.Close() or Flush()?

Edit:

You should always wrap stream writer in using blocks:

using (StreamWriter writer = new StreamWriter(@"somefile.txt"))
{

}

Upvotes: 3

Related Questions