-1
고정 파일을 거쳐 | 필요한 경우 프로그램이 올바르게 작동하고 콘솔에 올바르게 표시됩니다. 문제는 콘솔에서 파일의 줄에 줄을 쓸 수 없다는 것입니다. 모든 시도는 빈 파일로 끝나거나 개별 줄로 작성된 줄의 각 문자열로 끝납니다. 아래 코드는 파일에 출력을 써야하지만 파일은 비어있는 파일을 보여줍니다..NET Console.WriteLine() Console.SetOut
Imports System.IO
Module Module1
Sub Main()
Dim stdFormat As Integer() = {3, 13, 11, 5, 2, 2, 13, 14, 30, 15, 76, 80, 95, 100, 50, 2, 10, 30}
Using MyReader As New FileIO.TextFieldParser("SOURCE.txt")
MyReader.TextFieldType = FileIO.FieldType.FixedWidth
MyReader.FieldWidths = stdFormat
Dim currentRow As String()
While Not MyReader.EndOfData
Try
Dim rowType = MyReader.PeekChars(3)
If String.Compare(rowType, "Err") = 0 Then
Else
MyReader.SetFieldWidths(stdFormat)
End If
currentRow = MyReader.ReadFields
For Each newString In currentRow
Console.Write(newString & "|")
Next
Dim file = New FileStream("test.txt", FileMode.Append)
Dim standardOutput = Console.Out
Using writer = New StreamWriter(file)
Console.SetOut(writer)
Console.WriteLine()
Console.SetOut(standardOutput)
End Using
Catch ex As FileIO.MalformedLineException
End Try
End While
End Using
Console.ReadLine()
End Sub
End Module