I am trying to catch the Access Denied Exception when trying to upload a file via FTP using FluentFTP
try
{
client = new FtpClient(serverName, userName, password);
client.AutoConnect();
client.RetryAttempts = 3;
client.UploadFile(localPath, serverPath, FtpRemoteExists.Overwrite, false,FtpVerify.Retry);
}
catch (Exception ex)
{
if (ex is FtpException && ex.InnerException?.Message == "Access is denied. ")
{
//Do something here
throw ex;
}
throw;
}
I cannot rely on "Access is denied. " on this string but I don't know how to catch that Exception.