WebClient.OpenRead 메서드

정의

지정된 URI를 사용하여 리소스에서 다운로드한 데이터에 대한 읽을 수 있는 스트림을 엽니다.

오버로드

OpenRead(String)

String으로 지정된 URI를 사용하여 리소스에서 다운로드한 데이터에 대한 읽을 수 있는 스트림을 엽니다.

OpenRead(Uri)

Uri으로 지정된 URI를 사용하여 리소스에서 다운로드한 데이터에 대한 읽을 수 있는 스트림을 엽니다.

OpenRead(String)

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

String으로 지정된 URI를 사용하여 리소스에서 다운로드한 데이터에 대한 읽을 수 있는 스트림을 엽니다.

public:
 System::IO::Stream ^ OpenRead(System::String ^ address);
public System.IO.Stream OpenRead (string address);
member this.OpenRead : string -> System.IO.Stream
Public Function OpenRead (address As String) As Stream

매개 변수

address
String

String으로 지정된 URI입니다. 여기서 데이터를 다운로드합니다.

반환

리소스에서 데이터를 읽는 데 사용되는 Stream입니다.

예외

address 매개 변수가 null인 경우

BaseAddressaddress를 조합하여 만든 URI가 잘못된 경우

또는

데이터를 다운로드하는 동안 오류가 발생한 경우

예제

다음 코드 예제에서는 로 식별되는 uriString 리소스를 열고 시스템 콘솔에 결과를 표시합니다. 에서 반환 OpenRead 된 는 Stream 데이터를 읽을 때 닫힙니다.

// Create a new WebClient instance.
WebClient^ myWebClient = gcnew WebClient;
// Download home page data.
Console::WriteLine( "Accessing {0} ...", uriString );
// Open a stream to point to the data stream coming from the Web resource.
Stream^ myStream = myWebClient->OpenRead( uriString );

Console::WriteLine( "\nDisplaying Data :\n" );
StreamReader^ sr = gcnew StreamReader( myStream );
Console::WriteLine( sr->ReadToEnd() );

// Close the stream.
myStream->Close();
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Download home page data. 
Console.WriteLine("Accessing {0} ...",  uriString);						
// Open a stream to point to the data stream coming from the Web resource.
Stream myStream = myWebClient.OpenRead(uriString);

Console.WriteLine("\nDisplaying Data :\n");
StreamReader sr = new StreamReader(myStream);
Console.WriteLine(sr.ReadToEnd());

// Close the stream. 
myStream.Close();
    ' Create a new WebClient instance.
    Dim myWebClient As New WebClient()

    ' Download home page data. 
    Console.WriteLine("Accessing {0} ...", uriString)

    ' Open a stream to point to the data stream coming from the Web resource.
    Dim myStream As Stream = myWebClient.OpenRead(uriString)

    Console.WriteLine(ControlChars.Cr + "Displaying Data :" + ControlChars.Cr)
Dim sr As New StreamReader(myStream)
Console.WriteLine(sr.ReadToEnd())


    ' Close the stream.
    myStream.Close()

설명

메서드는 OpenRead 매개 변수로 Stream 지정된 address 리소스의 내용을 읽는 데 사용되는 instance 만듭니다. 이 메서드는 스트림을 여는 동안 차단합니다. 스트림을 기다리는 동안 실행을 계속하려면 메서드 중 OpenReadAsync 하나를 사용합니다.

속성이 BaseAddress 빈 문자열("")이 아니고 address 절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address 를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 이 QueryString 아니면 null에 추가됩니다 address.

이 메서드는 RETR 명령을 사용하여 FTP 리소스를 다운로드합니다. HTTP 리소스의 경우 GET 메서드가 사용됩니다.

참고

시스템 리소스가 부족하지 않도록 하려면 를 사용하여 완료되면 Stream 를 호출 Stream.Close 해야 합니다.

참고

애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.

적용 대상

OpenRead(Uri)

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

Uri으로 지정된 URI를 사용하여 리소스에서 다운로드한 데이터에 대한 읽을 수 있는 스트림을 엽니다.

public:
 System::IO::Stream ^ OpenRead(Uri ^ address);
public System.IO.Stream OpenRead (Uri address);
member this.OpenRead : Uri -> System.IO.Stream
Public Function OpenRead (address As Uri) As Stream

매개 변수

address
Uri

Uri으로 지정된 URI입니다. 여기서 데이터를 다운로드합니다.

반환

리소스에서 데이터를 읽는 데 사용되는 Stream입니다.

예외

address 매개 변수가 null인 경우

BaseAddressaddress를 조합하여 만든 URI가 잘못된 경우

또는

데이터를 다운로드하는 동안 오류가 발생한 경우

설명

메서드는 OpenRead 매개 변수로 Stream 지정된 address 리소스의 내용을 읽는 데 사용되는 instance 만듭니다. 이 메서드는 스트림을 여는 동안 차단합니다. 스트림을 기다리는 동안 실행을 계속하려면 메서드 중 OpenReadAsync 하나를 사용합니다.

속성이 BaseAddress 빈 문자열("")이 아니고 address 절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address 를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 이 QueryString 아니면 null에 추가됩니다 address.

이 메서드는 RETR 명령을 사용하여 FTP 리소스를 다운로드합니다. HTTP 리소스의 경우 GET 메서드가 사용됩니다.

참고

시스템 리소스가 부족하지 않도록 하려면 를 사용하여 완료되면 Stream 를 호출 Stream.Close 해야 합니다.

참고

애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.

적용 대상