System.Net.NetRes.GetWebStatusCodeString C# (CSharp) Method

GetWebStatusCodeString() public static method

public static GetWebStatusCodeString ( FtpStatusCode statusCode, string statusDescription ) : string
statusCode FtpStatusCode
statusDescription string
return string
        public static string GetWebStatusCodeString(FtpStatusCode statusCode, string statusDescription)
        {
            string webStatusCode = "(" + ((int)statusCode).ToString(NumberFormatInfo.InvariantInfo) + ")";
            string statusMessage = null;

            switch (statusCode)
            {
                case FtpStatusCode.ServiceNotAvailable:
                    statusMessage = SR.net_ftpstatuscode_ServiceNotAvailable;
                    break;
                case FtpStatusCode.CantOpenData:
                    statusMessage = SR.net_ftpstatuscode_CantOpenData;
                    break;
                case FtpStatusCode.ConnectionClosed:
                    statusMessage = SR.net_ftpstatuscode_ConnectionClosed;
                    break;
                case FtpStatusCode.ActionNotTakenFileUnavailableOrBusy:
                    statusMessage = SR.net_ftpstatuscode_ActionNotTakenFileUnavailableOrBusy;
                    break;
                case FtpStatusCode.ActionAbortedLocalProcessingError:
                    statusMessage = SR.net_ftpstatuscode_ActionAbortedLocalProcessingError;
                    break;
                case FtpStatusCode.ActionNotTakenInsufficientSpace:
                    statusMessage = SR.net_ftpstatuscode_ActionNotTakenInsufficientSpace;
                    break;
                case FtpStatusCode.CommandSyntaxError:
                    statusMessage = SR.net_ftpstatuscode_CommandSyntaxError;
                    break;
                case FtpStatusCode.ArgumentSyntaxError:
                    statusMessage = SR.net_ftpstatuscode_ArgumentSyntaxError;
                    break;
                case FtpStatusCode.CommandNotImplemented:
                    statusMessage = SR.net_ftpstatuscode_CommandNotImplemented;
                    break;
                case FtpStatusCode.BadCommandSequence:
                    statusMessage = SR.net_ftpstatuscode_BadCommandSequence;
                    break;
                case FtpStatusCode.NotLoggedIn:
                    statusMessage = SR.net_ftpstatuscode_NotLoggedIn;
                    break;
                case FtpStatusCode.AccountNeeded:
                    statusMessage = SR.net_ftpstatuscode_AccountNeeded;
                    break;
                case FtpStatusCode.ActionNotTakenFileUnavailable:
                    statusMessage = SR.net_ftpstatuscode_ActionNotTakenFileUnavailable;
                    break;
                case FtpStatusCode.ActionAbortedUnknownPageType:
                    statusMessage = SR.net_ftpstatuscode_ActionAbortedUnknownPageType;
                    break;
                case FtpStatusCode.FileActionAborted:
                    statusMessage = SR.net_ftpstatuscode_FileActionAborted;
                    break;
                case FtpStatusCode.ActionNotTakenFilenameNotAllowed:
                    statusMessage = SR.net_ftpstatuscode_ActionNotTakenFilenameNotAllowed;
                    break;
            }

            if (statusMessage != null && statusMessage.Length > 0)
            {
                webStatusCode += " " + statusMessage;
            }
            else
            {
                //
                // Otherwise try to map the base status.
                //
                if (statusDescription != null && statusDescription.Length > 0)
                {
                    webStatusCode += " " + statusDescription;
                }
            }

            return webStatusCode;
        }
    }

Usage Example

Example #1
0
 protected Exception GenerateException(FtpStatusCode code, string?statusDescription, Exception?innerException)
 {
     return(new WebException(SR.Format(SR.net_ftp_servererror, NetRes.GetWebStatusCodeString(code, statusDescription)),
                             innerException, WebExceptionStatus.ProtocolError, null));
 }
All Usage Examples Of System.Net.NetRes::GetWebStatusCodeString