public override WebResponse EndGetResponse(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("AsyncResult cannot be null!"); } if (!(asyncResult is FtpAsyncResult) || asyncResult != this.asyncResult) { throw new ArgumentException("AsyncResult is from another request!"); } FtpAsyncResult asyncFtpResult = (FtpAsyncResult)asyncResult; if (!asyncFtpResult.WaitUntilComplete(timeout, false)) { Abort(); throw new WebException("Transfer timed out.", WebExceptionStatus.Timeout); } CheckIfAborted(); asyncResult = null; if (asyncFtpResult.GotException) { throw asyncFtpResult.Exception; } return(asyncFtpResult.Response); }
public override Stream EndGetRequestStream(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } if (!(asyncResult is FtpAsyncResult)) { throw new ArgumentException("asyncResult"); } if (State == RequestState.Aborted) { throw new WebException("Request aborted", WebExceptionStatus.RequestCanceled); } if (asyncResult != this.asyncResult) { throw new ArgumentException("AsyncResult is from another request!"); } FtpAsyncResult res = (FtpAsyncResult)asyncResult; if (!res.WaitUntilComplete(timeout, false)) { Abort(); throw new WebException("Request timed out"); } if (res.GotException) { throw res.Exception; } return(res.Stream); }