Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FTP-re mentés:
- public static void SaveFile(string Content, string Filename, string FTPServer, string Username, string Password)
- {
- try
- {
- Uri requestUri = new Uri(Path.Combine(FTPServer, Filename));
- FtpWebRequest request = (FtpWebRequest)WebRequest.Create(requestUri);
- request.Credentials = new NetworkCredential(Username, Password);
- request.KeepAlive = false;
- request.Method = "STOR";
- request.UseBinary = true;
- request.ContentLength = Content.Length;
- request.Proxy = null;
- using (Stream stream = request.GetRequestStream())
- {
- byte[] bytes = new UnicodeEncoding().GetBytes(Content);
- stream.Write(bytes, 0, bytes.Length);
- }
- request.GetResponse();
- }
- catch (Exception ex)
- {
- MessageBox.Show("Hiba történt a fájl mentése során!\n\n" + ex.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment