FtpWebRequest.ContentOffset Property


Gets or sets a byte offset into the file being downloaded by this request.

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

Public Property ContentOffset As Long

Property Value

Type: System.Int64

An Int64 instance that specifies the file offset, in bytes. The default value is zero.

Exception Condition

A new value was specified for this property for a request that is already in progress.


The value specified for this property is less than zero.

Set the ContentOffset property when downloading a file from an FTP server. This offset indicates the position in the server's file that marks the start of the data to be downloaded. The offset is specified as the number of bytes from the start of the file; the offset of the first byte is zero.

Setting ContentOffset causes the FtpWebRequest to send a restart (REST) command to the server. This command is ignored by most FTP server implementations if you are uploading data to the server.

Changing ContentOffset after calling the GetRequestStream, BeginGetRequestStream, GetResponse, or BeginGetResponse method causes an InvalidOperationException exception.

The following code example demonstrates downloading part of a file from a server and appending the downloaded data to a local file.

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

.NET Framework
Available since 2.0
Return to top