现在在学习输入输出
在学习filestream的时候发现部门使用wirte 写回车换行
具体如下,代码是VB.NET的
Dim fsw As FileStream = New FileStream("C:\stream\1.txt", FileMode.Append, FileAccess.Write)
Dim msg1 As String = "地点"
Dim by1() As Byte = System.Text.Encoding.UTF8.GetBytes(msg1)
fsw.Write(by1, 0, by1.Length)
Dim by2(1) As Byte’直接写入回车换行的ASCII 值 但是下面发现还是不能实现换行
by2(0) = 13
by2(0) = 10
fsw.Write(by2, 0, by2.Length)‘无法回车换行
Dim msg2 As String = "\r\n 位置" ’这里也无法换行
Dim by3() As Byte
by3 = System.Text.Encoding.UTF8.GetBytes(msg2)
fsw.Write(by3, 0, by3.Length)
fsw.Close()
fsw.Dispose()
Dim fsw2 As FileStream = New FileStream("C:\stream\1.txt", FileMode.Append, FileAccess.Write)
Dim sw As StreamWriter = New StreamWriter(fsw2)
sw.WriteLine()
sw.WriteLine("时间")‘这里可以换行
sw.Close()
sw.Dispose()
fsw2.Close()
fsw2.Dispose()
我觉得把回车换行写入byte 数组,在使用write 进行写入,应该可以换行了,但是没有效果。另外\r\n 也不能实现...暂时没有C币 所以只希望好心人能帮助我。