private void ftpOKButton_Click(object sender, EventArgs e) { String sourcefilepath = pathToFileName; String ftpurl = fullFTPHostName; String ftpusername = ftpUserNameTextBox.Text.Trim(); String ftppassword = ftpPasswordTextBox.Text.Trim(); try { string filename = Path.GetFileName(sourcefilepath); string ftpfullpath = ftpurl; FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath); ftp.Credentials = new NetworkCredential(ftpusername, ftppassword); ftp.KeepAlive = true; ftp.UseBinary = true; ftp.Method = WebRequestMethods.Ftp.UploadFile; FileStream fs = File.OpenRead(sourcefilepath); 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(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
ContentLength
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)