Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string ftpUrl = ConfigurationManager.AppSettings["ftpAddress"];
- string ftpUsername = ConfigurationManager.AppSettings["ftpUsername"];
- string ftpPassword = ConfigurationManager.AppSettings["ftpPassword"];
- FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUrl + "Transactions.zip");
- request.Proxy = new WebProxy(); //-----The requested FTP command is not supported when using HTTP proxy.
- request.Method = WebRequestMethods.Ftp.UploadFile;
- request.Credentials = new NetworkCredential(ftpUsername, ftpPassword);
- StreamReader sourceStream = new StreamReader(fileToBeUploaded);
- byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
- sourceStream.Close();
- request.ContentLength = fileContents.Length;
- Stream requestStream = request.GetRequestStream();
- requestStream.Write(fileContents, 0, fileContents.Length);
- requestStream.Close();
- FtpWebResponse response = (FtpWebResponse)request.GetResponse();
- Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
- response.Close();
- StreamReader sourceStream = new StreamReader(fileToBeUploaded);
- byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
- byte[] fileContents = File.ReadAllBytes(fileToBeUploaded);
- using (var requestStream = request.GetRequestStream())
- {
- using (var input = File.OpenRead(fileToBeUploaded))
- {
- input.CopyTo(requestStream);
- }
- }
- string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
Add Comment
Please, Sign In to add comment