Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 1559

More about ftp.

$
0
0
Now I need to download a file that is in an FTP folder, I found the routine in C # but I do not master the language.

FtpWebRequest request = (FtpWebRequest)WebRequest.Create("servidor.com.br/.../logo.png"); request.Method = WebRequestMethods.Ftp.DownloadFile; request.Credentials = new NetworkCredential("usuario", "senha"); request.UsePassive = true; request.UseBinary = true; request.KeepAlive = true; FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); byte[] buffer = new byte[2048]; FileStream newFile = new FileStream("c:\\wwwroot\\exemplos\\logo.png", FileMode.Create); int readCount = responseStream.Read(buffer, 0, buffer.Length); while (readCount > 0) { //Escrever o arquivo newFile.Write(buffer, 0, readCount); readCount = responseStream.Read(buffer, 0, buffer.Length); } newFile.Close(); responseStream.Close(); response.Close();

thank you
 

Viewing all articles
Browse latest Browse all 1559

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>