In the company I work for, I have two servers: one that belongs to us and one third-party provider. I have to make a copy of the system files that is in the third-party provider for our local server. Basically a backup .
I'm using the FTPWebRequest
class to do list, download, and create directory if they do not exist.
While I was running the application on my PC, I was able to download it normally. When I send the application to our local server and put it to execute it happens the following error:
"The underlying connection was closed: The server committed a protocol violation."
in the following method:
WebUI.FTPClient.MakeDirFTP(String diretorio)
The method he claims to give the error is this:
public void MakeDirFTP(string diretorio) {
try {
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://diretorio/subDiretorio/Backup/" + diretorio);
request.Method = WebRequestMethods.Ftp.MakeDirectory;
request.Proxy = null;
request.UseBinary = true;
request.UsePassive = true;
request.Timeout = 6000000;
request.KeepAlive = true;
request.Credentials = new NetworkCredential(usuario, senha);
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
responseStream = response.GetResponseStream();
responseStream.Close();
response.Close();
} catch (Exception ex) {
throw ex;
}
}
This application runs in the same place as the backup . I've looked everywhere and I did not find an answer.