Here's my code:
for (int j = 0; j < bufferreader.Length; j++)
{
using (StreamWriter sw = File.AppendText(@"C:\Users\yamald\Documents\Normal.data"))
{
//sw.Write();
if (bufferreader.length != null)
{
sw.Write(bufferreader[j] + ",");
}
else
{
sw.WriteLine("\n");
}
}
}
How can I write a "\n" at the end of array to my file? The else
command does not run.
You need to place
sw.WriteLine("\n");
after the for loop.As the loop stops when j = bufferreader.length, the if statement is always true.
Also, I think that bufferreader.length will never be null as you never modify this variable. I think what you need is :