Filestream/Streamwriter not assigning values correctly
I have no experience with Filestream of StreamWriter so I am not sure if
there is something obvious that I am missing or not understanding.
I have a method that is using attributes from its current class, and
writing them to lines within a file, but it just seems to write blank
values to the file.
public void FileWrite()
{
FileStream fs = new FileStream("test.txt", FileMode.Append,
FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("Title = " + title);
sw.WriteLine("Name = " + fName);
sw.WriteLine("Last name = " + lName);
sw.WriteLine("Gender = " + gender);
sw.WriteLine("Medicare no = " + medicareNo);
sw.WriteLine("Height = " + height);
sw.WriteLine("Weight = " + weight);
sw.WriteLine("Age = " + age);
sw.WriteLine("Daily Recommended calories = " + cal);
sw.WriteLine("Ideal Weight = " + idealWeight);
sw.Flush();
sw.Close();
fs.Close();
Readfile();
}
Any help would be much appreciated as I have not worked with Filestream or
StreamWriter in the past.
No comments:
Post a Comment