StreamWriter weird behavior
Here's the code so we know what we're talking about
void WriteArrayToFile(double[] a, int rows, int cols, string file)
{
FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write);
TextWriter tw = new StreamWriter(fs);
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
tw.Write(String.Format("{0:0.####}", a[i * cols + j]) + " ");
}
tw.Write("\r\n");
}
tw.Close();
fs.Close();
}
So, this works fine. However, notice the " " at the end of the Write() in the for loop. If I make it any longer than one space (say, " "), I get gibberish in the output file, just random/corrupted/whatever you what to call it stuff. Even if I write individual spaces separately, I get the same behavior. Anything larger than one space produces a corrupted output file. There's nothing special about the input array, any double[] seems to produce this behavior. So, what gives?
Also, a completely unrelated question: how do I make it so that I don't receive answers to my threads, and other notifications, in e-mail form? It's annoying.