Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Net;
- using System.IO;
- namespace SimpleFTPDownload_CLI
- {
- class Program
- {
- static void Main(string[] args)
- {
- FTP_Download("ftp://muttismodemaus.mu.funpic.de/CIMG2824.JPG", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\CIMG2824.JPG", "muttismodemaus", "lenaundsusi");
- }
- public static bool FTP_Download(string Remote, string Local, string UserName, string Password)
- {
- WebClient Request = new WebClient();
- Request.Credentials = new NetworkCredential(UserName, Password);
- try
- {
- byte[] BinaryData = Request.DownloadData(Remote.ToString());
- FileStream File = new FileStream(Local, FileMode.Create, FileAccess.Write);
- File.Write(BinaryData, 0, BinaryData.Length);
- File.Close();
- }
- catch
- {
- return false;
- }
- return true;
- }
- }
- }
Add Comment
Please, Sign In to add comment