다음을 통해 공유


MemoryStream.Capacity 속성

이 스트림에 할당된 바이트 수를 가져오거나 설정합니다.

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

구문

‘선언
Public Overridable Property Capacity As Integer
‘사용 방법
Dim instance As MemoryStream
Dim value As Integer

value = instance.Capacity

instance.Capacity = value
public virtual int Capacity { get; set; }
public:
virtual property int Capacity {
    int get ();
    void set (int value);
}
/** @property */
public int get_Capacity ()

/** @property */
public void set_Capacity (int value)
public function get Capacity () : int

public function set Capacity (value : int)

속성 값

버퍼에서 스트림에 대해 사용할 수 있는 부분의 길이입니다.

예외

예외 형식 조건

ArgumentOutOfRangeException

음수 또는 스트림의 현재 길이보다 작은 용량이 설정되어 있는 경우

ObjectDisposedException

현재 스트림이 닫혀 있는 경우

NotSupportedException

용량을 수정할 수 없는 스트림에 set이 호출되는 경우

설명

파일을 만들고 파일에 텍스트를 쓰는 방법에 대한 예제를 보려면 방법: 파일에 텍스트 쓰기를 참조하십시오. 파일에서 텍스트를 읽는 방법에 대한 예제를 보려면 방법: 파일의 텍스트 읽기를 참조하십시오. 이진 파일을 읽거나 쓰는 방법에 대한 예제를 보려면 방법: 새로 만든 데이터 파일 읽기 및 쓰기를 참조하십시오.

Capacity는 시스템에서 제공하는 바이트 배열의 버퍼 길이입니다. Capacity를 스트림의 현재 길이보다 작은 값으로 설정할 수 없습니다.

예제

이 코드 예제는 MemoryStream 클래스에 대해 제공되는 보다 큰 예제의 일부입니다.

' Write the stream properties to the console.
Console.WriteLine( _
    "Capacity = {0}, Length = {1}, Position = {2}", _
    memStream.Capacity.ToString(), _
    memStream.Length.ToString(), _
    memStream.Position.ToString())
// Write the stream properties to the console.
Console.WriteLine(
    "Capacity = {0}, Length = {1}, Position = {2}\n",
    memStream.Capacity.ToString(), 
    memStream.Length.ToString(), 
    memStream.Position.ToString());
// Write the stream properties to the console.
Console::WriteLine( "Capacity = {0}, Length = {1}, "
"Position = {2}\n", memStream->Capacity.ToString(), memStream->Length.ToString(), memStream->Position.ToString() );
// Write the stream properties to the console.
Console.WriteLine(
    "Capacity = {0}, Length = {1}, Position = {2}\n", 
    (new Integer( memStream.get_Capacity())).ToString(),
    (new Long ( memStream.get_Length())).ToString(),
    (new Long ( memStream.get_Position())).ToString());

플랫폼

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에서 지원

참고 항목

참조

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

기타 리소스

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