1
In the company I work I have two servers: a place that belongs to us and a third party provider. I have to make a copy of the system files that is on the third party provider to our local server. Basically a backup.
I’m using the class FTPWebRequest
to list, download and create directory if they do not exist.
While I ran application on my PC, I could download normally. When I send the application to our local server and put to execute the following error happens:
"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 make the mistake 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 app runs in the same place as the backup. I’ve looked everywhere and I can’t find an answer.
Hello Peter. You could edit the question with the stack trace complete? Another thing, from your remote server you can access ftp with the application user and password and perform these operations (e. g.,
mkdir
)?– Anthony Accioly
Hi Anthony, I got it here, obg :D
– Pedro Nunes