Click here to Skip to main content
15,885,537 members
Articles / Programming Languages / C#

FTP component written with fully managed code

Rate me:
Please Sign up or sign in to vote.
4.78/5 (61 votes)
7 May 20021 min read 858.1K   14.7K   178  
A .NET FTP component
using System;
using System.Runtime.InteropServices;

namespace KCommon.Net.FTP
{
	[ComVisible(false)]
	public class FtpException : Exception
	{
		private FtpResponse	m_ftpResponse = null;
		
		internal FtpException(string message) : base(message)
		{
		}

		internal FtpException(string message, Exception inner) : base(message, inner)
		{
		}

		internal FtpException(string message, FtpResponse ftpResponse) : base(message)
		{
			m_ftpResponse	= ftpResponse;
		}
		public string ResponseMessage
		{
			get 
			{
				if(m_ftpResponse != null) 
					return m_ftpResponse.Message;
				else
					return "";
			}
		}
		public override string Message
		{
			get {return base.Message;}
		}
	}

	[ComVisible(false)]
	public class FtpServerDownException : FtpException
	{
		internal FtpServerDownException(FtpResponse ftpResponse) : base("FTP service was down.",ftpResponse)
		{
		}
	}

	[ComVisible(false)]
	public class FtpDataTransferException : FtpException
	{
		internal FtpDataTransferException() : base("Data transfer error: pervious transfer not finished.")
		{
		}
	}

	internal class FtpUserAbortException : FtpException
	{
		internal FtpUserAbortException() : base("File Transfer aborted by user.")
		{
		}
	}
	[ComVisible(false)]
	public class FtpResumeNotSupportedException : FtpException
	{
		internal FtpResumeNotSupportedException(FtpResponse ftpResponse) : base("Data transfer error: server don't support resuming", ftpResponse)
		{
		}
	}
	
	/*
	public class FtpServerNotFoundException : System.ComponentModel.Win32Exception
	{
		private string		m_serverName;

		internal FtpServerNotFoundException(string serverName, string errMsg, int errorCode) : base(errorCode, errMsg)
		{
			m_serverName = serverName;
		}
		public string Server
		{
			get {return m_serverName;}
		}
	}

	public class FtpFileChangedException : Exception
	{
	}
	*/
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Hong Kong Hong Kong
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions