SocketTools .NET Edition

HttpClient.GetData Method (String, MemoryStream)

Retrieve data from a web server and store it in a MemoryStream.

[Visual Basic]
Overloads Public Function GetData( _
   ByVal resourceName As String, _
   ByVal memStream As MemoryStream _
) As Boolean
[C#]
public bool GetData(
   string resourceName,
   MemoryStream memStream
);

Parameters

resourceName
A string that specifies the resource on the server that will be accessed. If the resource specifies a file, then the contents of the file will be returned by the server. If the resource specifies a script or other executable content, it will be executed and the output will be transferred to the local system. The resource name should be specified using an absolute path that begins with a leading slash character.
memStream
A System.IO.MemoryStream object that will contain the file data when the method returns. This stream must be open and writable.

Return Value

This method returns a Boolean value. If the method succeeds, the return value is true. If the method fails, the return value is false. To get extended error information, check the value of the LastError property.

Remarks

The GetData method transfers data from a file on the server to the local system, storing it in the specified MemoryStream. This method will cause the calling current thread to block until the file transfer completes, a timeout occurs or the transfer is canceled. During the transfer, the OnProgress event will fire periodically, enabling the application to update any user interface objects such as a progress bar.

The contents of the MemoryStream will be replaced by the contents of the file and the current position will be reset to the beginning of the stream. The stream must be open and writable, otherwise this method will throw System.NotSupportedException.

See Also

HttpClient Class | SocketTools Namespace | HttpClient.GetData Overload List