#region FTP Upload // Get the object used to communicate with the server. FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpSite + Path.GetFileName(newFile)); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(ftpUserNameTextBox.Text.Trim(), ftpPasswordTextBox.Text.Trim()); // Copy the contents of the file to the request stream. StreamReader sourceStream = null; sourceStream = new StreamReader("where-file-is-stored" + newFile); byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd()); request.KeepAlive = true; request.ReadWriteTimeout = 1200000; // 20 minutes sourceStream.Close(); request.ContentLength = fileContents.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(fileContents, 0, fileContents.Length); requestStream.Close(); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); response.Close(); #endregion
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)