private void envoiFTP(string table) { string path = @"D:\Temp\"; // string[] files = Directory.GetFiles(path,@"*.xml"); if (files != null) { foreach (string file in files) { fi = new FileInfo(file); string fileName = fi.Name; string fileurl = path + @"/" + fileName; string ftpFile = FtpServer + @"/" + fileName; FtpWebRequest myRequest = (FtpWebRequest)FtpWebRequest.Create(ftpFile); myRequest.Credentials = new NetworkCredential(FtpUser, FtpPassword); myRequest.Method = WebRequestMethods.Ftp.UploadFile; myRequest.Timeout = 1000000; myRequest.UseBinary = true; myRequest.KeepAlive = true; myRequest.ContentLength = fi.Length; byte[] buffer = new byte[4097]; int bytes = 0; int total_bytes = (int)fi.Length; System.IO.FileStream fs = fi.OpenRead(); System.IO.Stream rs = myRequest.GetRequestStream(); while (total_bytes > 0) { bytes = fs.Read(buffer, 0, buffer.Length); rs.Write(buffer, 0, bytes); total_bytes = total_bytes - bytes; } fs.Close(); rs.Close(); FtpWebResponse uploadResponse = (FtpWebResponse)myRequest.GetResponse(); uploadResponse.Close(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Randor