• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 691
  • Last Modified:

FTp componenet for .Net c#

Anybody knows a good ftp component in c#. I ahve search google and i found lots of them but I am just curiouse to see other programmers experince with them. Any good suggestion?
2 Solutions
You could try http://www.rebex.net/ftp.net and http://www.rebex.net/ftp.net/samples.aspx.

I really like it, but you could not trust me :-), as I'm biased (I work for Rebex)...
here's a simple winapi wrapper that i've used

using System;
using System.Runtime.InteropServices;
public class Ftp
   #region CloseConnection
   [DllImport("WININET.DLL", EntryPoint="InternetCloseHandle")]
   public static extern int CloseConnection(int HINet);

   #region Open
   [DllImport("WININET.DLL", EntryPoint="InternetOpenA")]
   public static extern int Open(string sAgent, int lAccessType, string sProxyName, string sProxyBypass, int lFlags);
   #region Connect
   [DllImport("WININET.DLL", EntryPoint="InternetConnectA")]
   public static extern int Connect(int hInternetSession, string sServerName, int nServerPort,
      string sUsername, string sPassword, int lService, int lFlags, int lContext);
   #region PutFile
   [DllImport("WININET.DLL", EntryPoint="FtpPutFileA")]
   public static extern bool PutFile(int hFtpSession, string lpszLocalFile, string lpszRemoteFile,
      int dwFlags, int dwContext);
   #region MakeDir
   [DllImport("WININET.DLL", EntryPoint="FtpCreateDirectoryA")]
   public static extern bool MakeDir(int hFtpSession, string Directory);
   #region FtpGetCurrentDirectoryA
   [DllImport("WININET.DLL", EntryPoint="FtpGetCurrentDirectoryA")]
   public static extern string GetCurrentDirectory(int FtpSession, string Directory);
   #region GetFile
   [DllImport("WININET.DLL", EntryPoint="FtpGetFileA")]
   public static extern bool GetFile(int hFtpSession, string lpszRemoteFile, string lpszNewFile,
      bool fFailIfExists, int dwFlagsAndAttributes, int dwFlags, int dwContext);

************* usage ******************
         int inetSsn = Ftp.Open("WebClientFtpTransfer", 0, null, null, 0);
         if (inetSsn == 0)
            lblResults.Text += "<span class=\"Error\">Could not connect to the FTP Server</span><br>";
         int ftpSsn = Ftp.Connect(inetSsn, ftpServer, 21, ftpUser, ftpPw, 1, 0, 0);

         // check to see if Internet session was successful
         if (ftpSsn == 0)
            lblResults.Text += "<span class=\"Error\">Could not connect to FTP Server: " + ftpServer + "</span><br>";

// ftpsession is the variable from the connect method
// local is the fully qualified path for the local file
// remote is the relative path and file name on the server
                  if (!Ftp.PutFile(FtpSession, local, remote, 0, 0))
                     ret.Append("<span class=\"error\">Error copying file: " + remote.Replace(FtpDirectory, "") + "</span><br>");
                     return ret;


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now