CSharpUtils.Net.FTP.DoDownload C# (CSharp) Метод

DoDownload() публичный Метод

Download a file, to be used in a loop until the file is completely downloaded
public DoDownload ( ) : long
Результат long
		public long DoDownload()
		{
			Byte[] bytes = new Byte[512];
			long bytes_got;

			try
			{
				bytes_got = data_sock.Receive(bytes, bytes.Length, 0);

				if (bytes_got <= 0)
				{
					// the download is done or an error occured
					CloseDataSocket();
					file.Close();
					file = null;

					ReadResponse();
					switch (response)
					{
						case 226:
						case 250:
							break;
						default:
							throw new Exception(responseStr);
					}

					SetBinaryMode(false);

					return bytes_got;
				}

				file.Write(bytes, 0, (int)bytes_got);
				bytes_total += bytes_got;
			}
			catch (Exception ex)
			{
				CloseDataSocket();
				file.Close();
				file = null;
				ReadResponse();
				SetBinaryMode(false);
				throw ex;
			}

			return bytes_got;
		}
	}