FtpWebRequest.KeepAlive Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a Boolean value that specifies whether the control connection to the FTP server is closed after the request completes.
public:
property bool KeepAlive { bool get(); void set(bool value); };
public bool KeepAlive { get; set; }
member this.KeepAlive : bool with get, set
Public Property KeepAlive As Boolean
Property Value
true
if the connection to the server should not be destroyed; otherwise, false
. The default value is true
.
Exceptions
A new value was specified for this property for a request that is already in progress.
Examples
The following code example retrieves and displays property values for a specified FtpWebRequest object.
Console::WriteLine( "Passive: {0} Keep alive: {1} Binary: {2} Timeout: {3}.", request->UsePassive, request->KeepAlive, request->UseBinary, request->Timeout == -1 ? "none" : request->Timeout.ToString() );
Console.WriteLine("Passive: {0} Keep alive: {1} Binary: {2} Timeout: {3}.",
request.UsePassive,
request.KeepAlive,
request.UseBinary,
request.Timeout == -1 ? "none" : request.Timeout.ToString()
);
Remarks
When the KeepAlive property is set to false
, the control connection is closed when you call the Close method.
Changing KeepAlive after calling the GetRequestStream, BeginGetRequestStream, GetResponse, or BeginGetResponse method causes an InvalidOperationException exception.