This documentation is archived and is not being maintained.

FileWebRequest.ContentLength Property

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

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

Property Value

The number of bytes of request data being sent.


Exception Type Condition
ArgumentException ContentLength is less than 0.


[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)

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

// Set the ContentLength property.
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.


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