FtpWebRequest.GetRequestStream Method ()

 

Retrieves the stream used to upload data to an FTP server.

Namespace:   System.Net
Assembly:  System (in System.dll)

Public Overrides Function GetRequestStream As Stream

Return Value

Type: System.IO.Stream

A writable Stream instance used to store data to be sent to the server by the current request.

Exception Condition
InvalidOperationException

BeginGetRequestStream has been called and has not completed.

- or -

An HTTP proxy is enabled, and you attempted to use an FTP command other than WebRequestMethods.Ftp.DownloadFile, WebRequestMethods.Ftp.ListDirectory, or WebRequestMethods.Ftp.ListDirectoryDetails.

WebException

A connection to the FTP server could not be established.

ProtocolViolationException

Set the request properties before calling the GetRequestStream method. After writing the data to the stream, you must close the stream prior to sending the request.

If you have not set the Method property to UploadFile or AppendFile, you cannot get the stream.

GetRequestStream blocks while waiting for the stream. To prevent this, call the BeginGetRequestStream method in place of GetRequestStream.

System_CAPS_noteNote

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.

Notes to Callers:

This method generates network traffic.

The following code example demonstrates copying a file to a request's data stream and sending a request to the server to upload the data and append it to a file.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: