CSharpUtils.Net.FTP.OpenDownload C# (CSharp) Method

OpenDownload() public method

Open a file for download
public OpenDownload ( string remote_filename, string local_filename, bool resume = false ) : void
remote_filename string The name of the file on the FTP server
local_filename string The name of the file to save as (Can include path to file)
resume bool Attempt resume if file exists
return void
		public void OpenDownload(string remote_filename, string local_filename, bool resume = false)
		{
			Connect();
			SetBinaryMode(true);

			bytes_total = 0;

			try
			{
				file_size = GetFileSize(remote_filename);
			}
			catch
			{
				file_size = 0;
			}

			if (resume && File.Exists(local_filename))
			{
				try
				{
					file = new FileStream(local_filename, FileMode.Open);
				}
				catch (Exception ex)
				{
					file = null;
					throw new Exception(ex.Message);
				}

				SendCommand("REST " + file.Length);
				ReadResponse();
				if (response != 350)
					throw new Exception(responseStr);
				file.Seek(file.Length, SeekOrigin.Begin);
				bytes_total = file.Length;
			}
			else
			{
				try
				{
					file = new FileStream(local_filename, FileMode.Create);
				}
				catch (Exception ex)
				{
					file = null;
					throw new Exception(ex.Message);
				}
			}

			OpenDataSocket();
			SendCommand("RETR " + remote_filename);
			ReadResponse();

			switch (response)
			{
				case 125:
				case 150:
					break;
				default:
					file.Close();
					file = null;
					throw new Exception(responseStr);
			}
			ConnectDataSocket();		// #######################################	

			return;
		}
		/// <summary>