Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string FTP_HOST = "Host IP";
- string FTP_USER = "User";
- string FTP_PASS = "Passw";
- string FTP_UPLOADBASEPATH = "Test";
- string filemanage = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), fileToSent);
- string source = Path.GetFileName(fileToSent);
- var ftp = (FtpWebRequest)WebRequest.Create(FTP_HOST + "/" + FTP_UPLOADBASEPATH + "/" + source);
- ftp.Credentials = new NetworkCredential(FTP_USER, FTP_PASS);
- ftp.KeepAlive = true;
- ftp.UseBinary = true;
- ftp.UsePassive = true;
- ftp.Method = WebRequestMethods.Ftp.UploadFile;
- FileStream fs = File.OpenRead(filemanage);
- byte[] buffer = new byte[fs.Length];
- fs.Read(buffer, 0, buffer.Length);
- fs.Close();
- Stream ftpstream = ftp.GetRequestStream();
- ftpstream.Write(buffer, 0, buffer.Length);
- ftpstream.Close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement