G***G 发帖数: 16778 | 1 in C#, you can use StreamWriter to write a file.
and you can use Filestream and StreamWriter to do the same thing.
What is differnce between the two methds?
for example,
A)
using (FileStream fs = new FileStream(fileName,FileMode.Append, FileAccess.
Write))
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine(something);
}
B)
using (StreamWriter sw = new StreamWriter(fileName, true))
{
sw.WriteLine(something);
} | d******k 发帖数: 4295 | 2 用FileStream catch的 exception信息更全面吧。 | H****S 发帖数: 1359 | 3 why dont you take a look at its source code ? I think underneath, `
StreamWriter` constructor that takes file name as argument will do a
conversion to `FileStream` and call the other constructor directly ? | a9 发帖数: 21638 | 4 FileStream是个raw stream
StreamWriter是外面包了层壳
【在 G***G 的大作中提到】 : in C#, you can use StreamWriter to write a file. : and you can use Filestream and StreamWriter to do the same thing. : What is differnce between the two methds? : for example, : A) : using (FileStream fs = new FileStream(fileName,FileMode.Append, FileAccess. : Write)) : using (StreamWriter sw = new StreamWriter(fs)) : { : sw.WriteLine(something);
|
|