110,566
社区成员
发帖
与我相关
我的任务
分享
private void DownloadFileFTP()
{
string inputfilepath = @"C:\Temp\FileName.exe";
string ftphost = "xxx.xx.x.xxx";
string ftpfilepath = "/Updater/Dir1/FileName.exe";
string ftpfullpath = "ftp://" + ftphost + ftpfilepath;
WebClient request = new WebClient();
request.Credentials = new NetworkCredential("UserName", "P@55w0rd");
byte[] fileData = request.DownloadData(ftpfullpath);
FileStream file = File.Create(inputfilepath);
file.Write(fileData, 0, fileData.Length);
file.Close();
MessageBox.Show("Download Complete");
}