TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Marius
NA
17
11.8k
StreamWriter weird behavior
Mar 24 2011 6:28 AM
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.
Reply
Answers (
1
)
how to read .eml files saved on local hard disk using .net
How to increase timeout values in GData.Client.