다음을 통해 공유


FileStream.Length 속성

스트림의 길이(바이트)를 가져옵니다.

네임스페이스: System.IO
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public Overrides ReadOnly Property Length As Long
‘사용 방법
Dim instance As FileStream
Dim value As Long

value = instance.Length
public override long Length { get; }
public:
virtual property long long Length {
    long long get () override;
}
/** @property */
public long get_Length ()
public override function get Length () : long

속성 값

스트림 길이(바이트)를 나타내는 long 값입니다.

예외

예외 형식 조건

NotSupportedException

이 스트림에 대한 CanSeekfalse인 경우

IOException

파일이 닫히는 등의 I/O 오류가 발생하는 경우

설명

다음 표에서는 일반적인 예 또는 관련된 I/O 작업의 예를 보여 줍니다.

수행 작업

참조 항목

텍스트 파일을 만듭니다.

방법: 파일에 텍스트 쓰기

텍스트 파일에 씁니다.

방법: 파일에 텍스트 쓰기

텍스트 파일에서 읽습니다.

방법: 파일의 텍스트 읽기

파일에 텍스트를 추가합니다.

방법: 로그 파일 열기 및 추가

File.AppendText

FileInfo.AppendText

파일 이름을 바꾸거나 이동합니다.

File.Move

FileInfo.MoveTo

파일을 복사합니다.

File.Copy

FileInfo.CopyTo

디렉터리 크기를 가져옵니다.

FileInfo.Length

파일 특성을 가져옵니다.

File.GetAttributes

파일의 특성을 설정합니다.

File.SetAttributes

하위 디렉터리를 만듭니다.

CreateSubdirectory

이진 파일에서 읽습니다.

방법: 새로 만든 데이터 파일 읽기 및 쓰기

이진 파일에 씁니다.

방법: 새로 만든 데이터 파일 읽기 및 쓰기

디렉터리의 파일을 참조하십시오.

Name

디렉터리의 파일을 크기순으로 정렬합니다.

GetFileSystemInfos

예제

다음 예제에서는 LengthPosition 속성을 사용하여 파일 끝 조건을 확인합니다.

If s.Length = s.Position Then
    Console.WriteLine("End of file has been reached.")
End If
if( s.Length==s.Position )
{
   Console.WriteLine("End of file has been reached.");
}
if ( s->Length == s->Position )
{
   Console::WriteLine( "End of file has been reached." );
}
if (s.get_Length() == s.get_Position()) {
    Console.WriteLine("End of file has been reached.");
}
if( s.Length==s.Position )
    Console.WriteLine("End of file has been reached.");

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

FileStream 클래스
FileStream 멤버
System.IO 네임스페이스

기타 리소스

파일 및 스트림 I/O
방법: 파일의 텍스트 읽기
방법: 파일에 텍스트 쓰기