FtpWebRequest.KeepAlive Właściwość

Definicja

Pobiera lub ustawia wartość określającą Boolean , czy połączenie sterujące z serwerem FTP jest zamknięte po zakończeniu żądania.

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

Wartość właściwości

true jeśli połączenie z serwerem nie powinno zostać zniszczone; w przeciwnym razie , false. Wartość domyślna to true.

Wyjątki

Określono nową wartość dla tej właściwości dla żądania, które jest już w toku.

Przykłady

Poniższy przykład kodu pobiera i wyświetla wartości właściwości dla określonego FtpWebRequest obiektu.

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()
);

Uwagi

Gdy właściwość jest ustawiona KeepAlive na false, połączenie sterujące jest zamykane po wywołaniu Close metody.

Zmiana KeepAlive po wywołaniu GetRequestStreammetody , BeginGetRequestStream, GetResponselub BeginGetResponse powoduje InvalidOperationException wyjątek.

Dotyczy

Zobacz też