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[]

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

예제

이 예제에서는 함수를 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할 수 있도록 다음과 같은 범용 가정이 수행됩니다.

  • 숫자 데이터는 항상 소수 구분 기호로 마침표로 작성됩니다.

  • 데이터의 #TRUE##FALSE# 경우 Boolean 인쇄됩니다. True 로캘에 관계없이 키워드 및 False 키워드는 변환되지 않습니다.

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

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

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

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을 참조하십시오.

적용 대상

추가 정보