将人的内容写入文件
名字: Abcd
第二名:Tsfsdfs
为此,我编写了一个示例应用程序
namespace BinaryStream
{
class Program
{
static void Main(string[] args)
{
StreamWriter binWriter = new StreamWriter(@"c:\happybirthday.txt");
string name = "Sachin";
string secondname = "tendulkar";
string wishes = "happy birthday";
string firstname = string.Format("FirstName: {0} \n", name);
binWriter.Write(firstname);
string sn = string.Format("SecondName: {0} \n", secondname);
binWriter.Write(sn);
binWriter.Close();
}
}
}
如果我在记事本中打开内容,下一行没有显示字符串这是什么原因?格式部分是否正确?