Export (0) Print
Expand All

FileWebRequest.ContentLength Property

Gets or sets the content length of the data being sent.

[Visual Basic]
Overrides Public Property ContentLength As Long
[C#]
public override long ContentLength {get; set;}
[C++]
public: __property __int64 get_ContentLength();
public: __property void set_ContentLength(__int64);
[JScript]
public override function get ContentLength() : long;
public override function set ContentLength(long);

Property Value

The number of bytes of request data being sent.

Exceptions

Exception Type Condition
ArgumentException ContentLength is less than 0.

Example

[Visual Basic, C#, C++] The following example sets the content length of the data being sent. Refer to the complete example in the FileWebRequest class.

[Visual Basic] 
' Set the ContentLength property.
myFileWebRequest.ContentLength = byteArray.Length

Dim contentLength As String = myFileWebRequest.ContentLength.ToString()

Console.WriteLine(ControlChars.Lf + "The content length is {0}.", contentLength)


[C#] 
// Set the ContentLength property.
myFileWebRequest.ContentLength=byteArray.Length;  
string contentLength = myFileWebRequest.ContentLength.ToString();
Console.WriteLine("\nThe content length is {0}.", contentLength);  

[C++] 
// Set the ContentLength property.
myFileWebRequest->ContentLength=byteArray->Length;
String* contentLength = myFileWebRequest->ContentLength.ToString();
Console::WriteLine(S"\nThe content length is {0}.", contentLength);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

FileWebRequest Class | FileWebRequest Members | System.Net Namespace

Show:
© 2015 Microsoft