Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Simple FTP Download

Posted on May 21, 2014October 26, 2015 By David Kittell
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace FTPTransfer
	{
	public partial class Form1 : Form
		{
		public string sFTPServer = "ftp.domain.com";
		public string sFTPUser = "ftpuser";
		public string sFTPPass = "ftppassword";

		public Form1 ()
			{
			InitializeComponent();
			}

		private void Form1_Load (object sender, EventArgs e)
			{
			DownloadFileFTP("/filename.pdf", @"C:Temp", true);
			}

		private void DownloadFileFTP (string sFTPFilePath, string sDownloadFilePath, bool bKeepFileName)
			{

			string ftpfullpath = "ftp://" + sFTPServer + sFTPFilePath;

			using (WebClient request = new WebClient())
				{
				request.Credentials = new NetworkCredential(sFTPUser, sFTPPass);
				byte[] fileData = request.DownloadData(ftpfullpath);

				if (bKeepFileName == true)
					{
					sDownloadFilePath += sFTPFilePath;
					}

				using (FileStream file = File.Create(sDownloadFilePath))
					{
					file.Write(fileData, 0, fileData.Length);
					file.Close();
					}
				MessageBox.Show("Download Complete");
				request.Dispose();
				}
			}

		}

	}

Reference: http://stackoverflow.com/questions/2781654/ftpwebrequest-download-file

Originally Posted on May 21, 2014
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code CSharp

Post navigation

Previous post
Next post

Related Posts

Enable/Disable Desktop Saves

Posted on November 9, 2013October 26, 2015

WARNING: Backup the computer you try these scripts on before you run these. These scripts will enable/disable the ability to save anything to the desktop. Windows Registry Editor Version 5.00 [HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer] "NoSaveSettings"=dword:00000001 Windows Registry Editor Version 5.00 [HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer] "NoSaveSettings"=dword:00000000 Originally Posted on November 9, 2013Last Updated on October 26, 2015…

Read More

PowerShell – Add Windows Feature

Posted on December 15, 2015

First figure out what features are installed Import-Module ServerManager -Verbose Get-WindowsFeature To add a feature look at the listing from Get-WindowsFeature and it will have something like XPS-Viewer or Web-Http-Redirect Import-Module ServerManager -Verbose Add-WindowsFeature Web-Http-Redirect All information on this site is shared with the intention to help. Before any source…

Read More

Content Audit

Posted on July 19, 2013October 26, 2015

SELECT COUNT(*) AS "# Of Templates" FROM templates_tbl SELECT DISTINCT template_id AS "Template ID" ,count(*) AS "Usage" FROM content GROUP BY template_id ORDER BY "Template ID" SELECT [content].content_id ,[content].content_title ,templates_tbl.template_filename FROM [content] INNER JOIN templates_tbl ON [content].template_id = templates_tbl.template_id WHERE templates_tbl.template_filename LIKE ‘%templates%’ ORDER BY templates_tbl.template_filename ,[content].content_id ,[content].content_title SELECT count(*)…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
  • Mac OS X Terminal - Parallels - Reset Windows User Password
  • Bleaching Wool using Hydrogen Peroxide

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
  • Mac OS X Terminal - Parallels - Reset Windows User Password
  • Bleaching Wool using Hydrogen Peroxide
  • PowerShell - IPv4 Range
©2025 David Kittell | WordPress Theme by SuperbThemes