WebClient.DownloadData 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
리소스를 지정된 URI에서 Byte 배열로 다운로드합니다.
오버로드
DownloadData(String) |
리소스를 지정된 URI에서 Byte 배열로 다운로드합니다. |
DownloadData(Uri) |
리소스를 지정된 URI에서 Byte 배열로 다운로드합니다. |
DownloadData(String)
- Source:
- WebClient.cs
- Source:
- WebClient.cs
- Source:
- WebClient.cs
리소스를 지정된 URI에서 Byte 배열로 다운로드합니다.
public:
cli::array <System::Byte> ^ DownloadData(System::String ^ address);
public byte[] DownloadData (string address);
member this.DownloadData : string -> byte[]
Public Function DownloadData (address As String) As Byte()
매개 변수
- address
- String
데이터를 다운로드할 URI입니다.
반환
다운로드한 리소스를 포함하는 Byte 배열입니다.
예외
address
매개 변수가 null
인 경우
메서드가 여러 스레드에서 동시에 호출된 경우
예제
다음 코드 예제에서는 서버에서 데이터를 요청하고 반환된 데이터를 표시합니다. 요청된 remoteUri
데이터에 대한 유효한 URI가 포함되어 있다고 가정합니다.
Console::Write( "\nPlease enter a URI (e.g. http://www.contoso.com): " );
String^ remoteUri = Console::ReadLine();
// Create a new WebClient instance.
WebClient^ myWebClient = gcnew WebClient;
// Download home page data.
Console::WriteLine( "Downloading {0}", remoteUri );
// Download the Web resource and save it into a data buffer.
array<Byte>^ myDataBuffer = myWebClient->DownloadData( remoteUri );
// Display the downloaded data.
String^ download = Encoding::ASCII->GetString( myDataBuffer );
Console::WriteLine( download );
Console::WriteLine( "Download successful." );
Console.Write("\nPlease enter a URI (for example, http://www.contoso.com): ");
string remoteUri = Console.ReadLine();
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Download home page data.
Console.WriteLine("Downloading " + remoteUri);
// Download the Web resource and save it into a data buffer.
byte[] myDataBuffer = myWebClient.DownloadData (remoteUri);
// Display the downloaded data.
string download = Encoding.ASCII.GetString(myDataBuffer);
Console.WriteLine(download);
Console.WriteLine("Download successful.");
Console.Write(ControlChars.Cr + "Please enter a Url(for example, http://www.msn.com): ")
Dim remoteUrl As String = Console.ReadLine()
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Download the home page data.
Console.WriteLine(("Downloading " + remoteUrl))
' DownloadData() method takes a 'uriRemote.ToString()' and downloads the Web resource and saves it into a data buffer.
Dim myDatabuffer As Byte() = myWebClient.DownloadData(remoteUrl)
' Display the downloaded data.
Dim download As String = Encoding.ASCII.GetString(myDataBuffer)
Console.WriteLine(download)
Console.WriteLine("Download successful.")
설명
메서드는 DownloadData 매개 변수로 지정된 URI를 사용하여 리소스를 address
다운로드합니다. 이 메서드는 리소스를 다운로드하는 동안 차단합니다. 리소스를 다운로드하고 서버의 응답을 기다리는 동안 계속 실행하려면 메서드 중 DownloadDataAsync 하나를 사용합니다.
속성이 BaseAddress 빈 문자열("")이 아니고 address
절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address
를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address
.
이 메서드는 RETR 명령을 사용하여 FTP 리소스를 다운로드합니다. HTTP 리소스의 경우 GET 메서드가 사용됩니다.
참고
애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.
적용 대상
DownloadData(Uri)
- Source:
- WebClient.cs
- Source:
- WebClient.cs
- Source:
- WebClient.cs
리소스를 지정된 URI에서 Byte 배열로 다운로드합니다.
public:
cli::array <System::Byte> ^ DownloadData(Uri ^ address);
public byte[] DownloadData (Uri address);
member this.DownloadData : Uri -> byte[]
Public Function DownloadData (address As Uri) As Byte()
매개 변수
반환
다운로드한 리소스를 포함하는 Byte 배열입니다.
예외
address
매개 변수가 null
인 경우
설명
메서드는 DownloadData 매개 변수로 지정된 URI를 사용하여 리소스를 address
다운로드합니다. 이 메서드는 리소스를 다운로드하는 동안 차단합니다. 리소스를 다운로드하고 서버의 응답을 기다리는 동안 계속 실행하려면 메서드 중 DownloadDataAsync 하나를 사용합니다.
속성이 BaseAddress 빈 문자열("")이 아니고 address
절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address
를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address
.
이 메서드는 RETR 명령을 사용하여 FTP 리소스를 다운로드합니다. HTTP 리소스의 경우 GET 메서드가 사용됩니다.
참고
애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.
적용 대상
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기