WebClient.OpenWrite 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 URI를 사용하여 리소스에 데이터를 쓰는 데 사용되는 스트림을 엽니다.
오버로드
OpenWrite(String) |
지정된 리소스에 데이터를 쓰는 데 사용되는 스트림을 엽니다. |
OpenWrite(Uri) |
지정된 리소스에 데이터를 쓰는 데 사용되는 스트림을 엽니다. |
OpenWrite(String, String) |
지정된 메서드를 사용하여 지정된 리소스에 데이터를 쓰는 데 사용되는 스트림을 엽니다. |
OpenWrite(Uri, String) |
지정된 메서드를 사용하여 지정된 리소스에 데이터를 쓰는 데 사용되는 스트림을 엽니다. |
OpenWrite(String)
- Source:
- WebClient.cs
- Source:
- WebClient.cs
- Source:
- WebClient.cs
지정된 리소스에 데이터를 쓰는 데 사용되는 스트림을 엽니다.
public:
System::IO::Stream ^ OpenWrite(System::String ^ address);
public System.IO.Stream OpenWrite (string address);
member this.OpenWrite : string -> System.IO.Stream
Public Function OpenWrite (address As String) As Stream
매개 변수
- address
- String
데이터를 받을 리소스의 URI입니다.
반환
리소스에 데이터를 쓰는 데 사용되는 Stream입니다.
예외
address
매개 변수가 null
인 경우
예제
다음 코드 예제에서는 명령줄에서 데이터를 읽고 를 사용하여 OpenWrite 데이터를 쓰기 위한 스트림을 가져옵니다. 에서 OpenWrite 반환된 는 Stream 데이터가 전송된 후 닫힙니다.
String^ uriString;
Console::Write( "\nPlease enter the URI to post data to: " );
uriString = Console::ReadLine();
Console::WriteLine( "\nPlease enter the data to be posted to the URI {0}:", uriString );
String^ postData = Console::ReadLine();
// Apply Ascii Encoding to obtain an array of bytes.
array<Byte>^ postArray = Encoding::ASCII->GetBytes( postData );
// Create a new WebClient instance.
WebClient^ myWebClient = gcnew WebClient;
// postStream implicitly sets HTTP POST as the request method.
Console::WriteLine( "Uploading to {0} ...", uriString );
Stream^ postStream = myWebClient->OpenWrite( uriString );
postStream->Write( postArray, 0, postArray->Length );
// Close the stream and release resources.
postStream->Close();
Console::WriteLine( "\nSuccessfully posted the data." );
string uriString;
Console.Write("\nPlease enter the URI to post data to : ");
uriString = Console.ReadLine();
Console.WriteLine("\nPlease enter the data to be posted to the URI {0}:",uriString);
string postData = Console.ReadLine();
// Apply Ascii Encoding to obtain an array of bytes.
byte[] postArray = Encoding.ASCII.GetBytes(postData);
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// postStream implicitly sets HTTP POST as the request method.
Console.WriteLine("Uploading to {0} ...", uriString); Stream postStream = myWebClient.OpenWrite(uriString);
postStream.Write(postArray,0,postArray.Length);
// Close the stream and release resources.
postStream.Close();
Console.WriteLine("\nSuccessfully posted the data.");
Dim uriString As String
Console.Write(ControlChars.Cr + "Please enter the URI to post data to : ")
uriString = Console.ReadLine()
Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted to the URI {0}:", uriString)
Dim postData As String = Console.ReadLine()
' Apply ASCII Encoding to obtain an array of bytes .
Dim postArray As Byte() = Encoding.ASCII.GetBytes(postData)
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
Console.WriteLine("Uploading to {0} ...", uriString)
' OpenWrite implicitly sets HTTP POST as the request method.
Dim postStream As Stream = myWebClient.OpenWrite(uriString)
postStream.Write(postArray, 0, postArray.Length)
' Close the stream and release resources.
postStream.Close()
Console.WriteLine(ControlChars.Cr + "Successfully posted the data.")
설명
메서드는 OpenWrite 리소스에 데이터를 보내는 데 사용되는 쓰기 가능한 스트림을 반환합니다. 이 메서드는 스트림을 여는 동안 차단합니다. 스트림을 기다리는 동안 계속 실행하려면 메서드 중 OpenWriteAsync 하나를 사용합니다.
속성이 BaseAddress 빈 문자열("")이 아니고 address
절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address
를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address
.
이 메서드는 STOR 명령을 사용하여 FTP 리소스를 업로드합니다. HTTP 리소스의 경우 POST 메서드가 사용됩니다.
참고
애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework의 네트워크 추적을 참조하세요.
적용 대상
OpenWrite(Uri)
- Source:
- WebClient.cs
- Source:
- WebClient.cs
- Source:
- WebClient.cs
지정된 리소스에 데이터를 쓰는 데 사용되는 스트림을 엽니다.
public:
System::IO::Stream ^ OpenWrite(Uri ^ address);
public System.IO.Stream OpenWrite (Uri address);
member this.OpenWrite : Uri -> System.IO.Stream
Public Function OpenWrite (address As Uri) As Stream
매개 변수
- address
- Uri
데이터를 받을 리소스의 URI입니다.
반환
리소스에 데이터를 쓰는 데 사용되는 Stream입니다.
예외
address
매개 변수가 null
인 경우
설명
메서드는 OpenWrite 리소스에 데이터를 보내는 데 사용되는 쓰기 가능한 스트림을 반환합니다. 이 메서드는 스트림을 여는 동안 차단합니다. 스트림을 기다리는 동안 계속 실행하려면 메서드 중 OpenWriteAsync 하나를 사용합니다.
속성이 BaseAddress 빈 문자열("")이 아니고 address
절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address
를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address
.
이 메서드는 STOR 명령을 사용하여 FTP 리소스를 업로드합니다. HTTP 리소스의 경우 POST 메서드가 사용됩니다.
참고
애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework의 네트워크 추적을 참조하세요.
적용 대상
OpenWrite(String, String)
- Source:
- WebClient.cs
- Source:
- WebClient.cs
- Source:
- WebClient.cs
지정된 메서드를 사용하여 지정된 리소스에 데이터를 쓰는 데 사용되는 스트림을 엽니다.
public:
System::IO::Stream ^ OpenWrite(System::String ^ address, System::String ^ method);
public System.IO.Stream OpenWrite (string address, string? method);
public System.IO.Stream OpenWrite (string address, string method);
member this.OpenWrite : string * string -> System.IO.Stream
Public Function OpenWrite (address As String, method As String) As Stream
매개 변수
- address
- String
데이터를 받을 리소스의 URI입니다.
- method
- String
리소스에 데이터를 보내는 데 사용되는 메서드입니다. null인 경우 http의 기본값은 POST이고 ftp의 기본값은 STOR입니다.
반환
리소스에 데이터를 쓰는 데 사용되는 Stream입니다.
예외
address
매개 변수가 null
인 경우
예제
다음 코드 예제에서는 명령줄에서 데이터를 읽고 를 사용하여 OpenWrite 데이터를 작성하는 데 사용되는 스트림을 가져옵니다. Stream 데이터를 보내려면 에서 OpenWrite 반환된 를 닫아야 합니다.
String^ uriString;
Console::Write( "\nPlease enter the URI to post data to: " );
uriString = Console::ReadLine();
Console::WriteLine( "\nPlease enter the data to be posted to the URI {0}:", uriString );
String^ postData = Console::ReadLine();
// Apply ASCII encoding to obtain an array of bytes .
array<Byte>^ postArray = Encoding::ASCII->GetBytes( postData );
// Create a new WebClient instance.
WebClient^ myWebClient = gcnew WebClient;
Console::WriteLine( "Uploading to {0} ...", uriString );
Stream^ postStream = myWebClient->OpenWrite( uriString, "POST" );
postStream->Write( postArray, 0, postArray->Length );
// Close the stream and release resources.
postStream->Close();
Console::WriteLine( "\nSuccessfully posted the data." );
string uriString;
Console.Write("\nPlease enter the URI to post data to : ");
uriString = Console.ReadLine();
Console.WriteLine("\nPlease enter the data to be posted to the URI {0}:",uriString);
string postData = Console.ReadLine();
// Apply ASCII encoding to obtain an array of bytes .
byte[] postArray = Encoding.ASCII.GetBytes(postData);
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
Console.WriteLine("Uploading to {0} ...", uriString);
Stream postStream = myWebClient.OpenWrite(uriString,"POST");
postStream.Write(postArray,0,postArray.Length);
// Close the stream and release resources.
postStream.Close();
Console.WriteLine("\nSuccessfully posted the data.");
Dim uriString As String
Console.Write(ControlChars.Cr + "Please enter the URI to post data to : ")
uriString = Console.ReadLine()
Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted to the URI {0}:", uriString)
Dim postData As String = Console.ReadLine()
' Apply ASCII encoding to obtain an array of bytes.
Dim postArray As Byte() = Encoding.ASCII.GetBytes(postData)
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
Console.WriteLine("Uploading to {0} ...", uriString)
Dim postStream As Stream = myWebClient.OpenWrite(uriString, "POST")
postStream.Write(postArray, 0, postArray.Length)
' Close the stream and release resources.
postStream.Close()
Console.WriteLine(ControlChars.Cr + "Successfully posted the data.")
설명
메서드는 OpenWrite 리소스에 데이터를 보내는 데 사용되는 쓰기 가능한 스트림을 반환합니다. 기본 요청은 매개 변수에 지정된 메서드를 사용하여 method
이루어집니다. 스트림을 닫으면 데이터가 서버로 전송됩니다. 이 메서드는 스트림을 여는 동안 차단합니다. 스트림을 기다리는 동안 계속 실행하려면 메서드 중 OpenWriteAsync 하나를 사용합니다.
매개 변수가 서버에서 method
인식할 수 없는 메서드를 지정하는 경우 기본 프로토콜 클래스는 발생하는 사항을 결정합니다. 일반적으로 WebException 는 오류를 나타내기 위해 속성이 설정된 상태에서 Status throw됩니다.
속성이 BaseAddress 빈 문자열("")이 아니고 address
절대 주소를 address
지정하지 않는 경우 는 요청된 데이터의 절대 URI를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address
.
참고
애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework의 네트워크 추적을 참조하세요.
적용 대상
OpenWrite(Uri, String)
- Source:
- WebClient.cs
- Source:
- WebClient.cs
- Source:
- WebClient.cs
지정된 메서드를 사용하여 지정된 리소스에 데이터를 쓰는 데 사용되는 스트림을 엽니다.
public:
System::IO::Stream ^ OpenWrite(Uri ^ address, System::String ^ method);
public System.IO.Stream OpenWrite (Uri address, string? method);
public System.IO.Stream OpenWrite (Uri address, string method);
member this.OpenWrite : Uri * string -> System.IO.Stream
Public Function OpenWrite (address As Uri, method As String) As Stream
매개 변수
- address
- Uri
데이터를 받을 리소스의 URI입니다.
- method
- String
리소스에 데이터를 보내는 데 사용되는 메서드입니다. null인 경우 http의 기본값은 POST이고 ftp의 기본값은 STOR입니다.
반환
리소스에 데이터를 쓰는 데 사용되는 Stream입니다.
예외
address
매개 변수가 null
인 경우
설명
메서드는 OpenWrite 리소스에 데이터를 보내는 데 사용되는 쓰기 가능한 스트림을 반환합니다. 이 메서드는 스트림을 여는 동안 차단합니다. 스트림을 기다리는 동안 계속 실행하려면 메서드 중 OpenWriteAsync 하나를 사용합니다.
속성이 BaseAddress 빈 문자열("")이 아니고 address
절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address
를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address
.
참고
애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework의 네트워크 추적을 참조하세요.
적용 대상
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기