FileSystem.WriteLine(Int32, Object[]) 메서드

정의

순차 파일에 데이터를 씁니다. Write로 작성된 데이터는 일반적으로 Input을 사용하여 파일에서 읽습니다.

public:
 static void WriteLine(int FileNumber, ... cli::array <System::Object ^> ^ Output);
public static void WriteLine (int FileNumber, params object[] Output);
static member WriteLine : int * obj[] -> unit
Public Sub WriteLine (FileNumber As Integer, ParamArray Output As Object())

매개 변수

FileNumber
Int32

필수 요소. 유효한 파일 번호가 포함된 Integer 식입니다.

Output
Object[]

선택 사항입니다. 파일에 쓸 쉼표로 구분된 하나 이상의 식입니다.

예제

이 예제에서는 함수를 Write 사용하여 순차적 파일에 원시 데이터를 씁니다.

' Open file for output.
FileOpen(1, "TestFile.txt", OpenMode.Output)
' Print text to the file. The quotation marks will be in the display.
Write(1, "This is a test.")
' Go to the next line.
WriteLine(1)
' Skip a line.
WriteLine(1)
' Print in two print zones. You will see commas and quotation marks
' in the output file.
WriteLine(1, "Zone 1", SPC(10), "Zone 2")
' Build a longer string before calling WriteLine.
WriteLine(1, "Hello" & "  " & "World")
' Include five leading spaces.
WriteLine(1, SPC(5), "Leading spaces")
' Print a word starting at column 10.
WriteLine(1, TAB(10), "Hello")

' Assign Boolean and Date values.
Dim aBool As Boolean
Dim aDate As DateTime
aBool = False
aDate = DateTime.Parse("February 12, 1969")

' Dates and Booleans are translated using locale settings of 
' your system.
WriteLine(1, aBool & " is a Boolean value.")
WriteLine(1, aDate & " is a date.")
' Close the file.
FileClose(1)

' Contents of TestFile.txt
'"This is a test.",
'
'"Zone 1",          "Zone 2"
'"Hello  World"
'     "Leading spaces"
'         ,"Hello"
'"False is a Boolean value."
'"2/12/1969 is a date."

설명

WriteWriteLine 함수는 이전 버전과의 호환성을 위해 제공되며 성능에 영향을 줄 수 있습니다. 비 레거시 애플리케이션의 경우는 My.Computer.FileSystem 개체는 더 나은 성능을 제공 합니다. 자세한 내용은 Visual Basic을 사용한 파일 액세스를 참조하세요.

를 생략 Output하면 빈 줄이 파일에 인쇄됩니다. 여러 식을 쉼표로 구분할 수 있습니다.

함수와 Print 달리 함수는 Write 파일에 기록될 때 항목과 문자열 주위에 따옴표 사이에 쉼표를 삽입합니다. 목록에 명시적 구분 기호를 넣을 필요가 없습니다. 가 파일에 데이터를 쓰는 데 사용되는 경우 Write 숫자, 날짜, Booleannull 및 Error 데이터 형식만 지원됩니다. 로캘에 관계없이 를 사용하여 Input데이터를 항상 읽고 올바르게 해석할 수 있도록 다음과 같은 범용 가정이 따릅니다.

  • 숫자 데이터는 항상 마침표 를 10진수 구분 기호로 사용하여 작성됩니다.

  • 데이터의 #TRUE# 경우 Boolean 또는 #FALSE# 가 인쇄됩니다. TrueFalse 키워드는 로캘에 관계없이 번역되지 않습니다.

  • 날짜 데이터는 범용 날짜 형식을 사용하여 파일에 기록됩니다. 날짜 또는 시간 구성 요소가 없거나 0이면 제공된 부분만 파일에 기록됩니다.

  • 데이터가 비어 있으면 Output 파일에 아무 것도 기록되지 않습니다. 그러나 null 데이터의 경우 는 #NULL# 기록됩니다.

  • 데이터의 경우 Error 출력이 로 #ERROR errorcode#표시됩니다. Error 로캘에 관계없이 키워드(keyword) 변환되지 않습니다.

WriteLine는 파일에 마지막 문자를 쓴 후 줄 바꿈 문자Output(즉, 캐리지 리턴/줄 바꿈 또는 Chr(13) + Chr(10))를 삽입합니다.

큰따옴표 또는 ""를 사용하여 문자열에 따옴표를 포함할 수 있습니다. 예를 들면 다음과 같습니다.

Dim x As String = "Double quotation marks aren't ""difficult"" to handle."

는 값이 인 문자열을 반환합니다 Double quotation marks aren't "difficult" to handle.

또는 WriteLine 함수를 사용하여 Write 파일에 쓰려면 열거형에서 FileIOPermissionAccess 액세스해야 합니다Append. 자세한 내용은 FileIOPermissionAccess을 참조하십시오.

적용 대상

추가 정보