We help IT Professionals succeed at work.

Connecting to FTP

CPSRI asked
Last Modified: 2012-05-11
   I want to connect to my FTP server through ASP,is it possible to connect?if possible please let me know the solution for this,because i have tried in many ways to connect.But it was not connected.Please let me the solution or any releted URLs for this.

 Thank you
Watch Question

You have mentioned here that you are not able to connect. but you didn't mention it what problem you are facing when you try to connect.
let me know.


Hi sanjithml,
    Actually i don't  know how to connect. But i Tried like 'SQLConnection String' but it not working. Could you Help Me  how to Connect and how many ways to connect through ASP.NET Page.
can u ftp manually to a site from command line?
does your ftp site need authentication?

try ftp ftp.sunfreeware.com from command line

let me know the problem you face...
What version of .NET are you using?
Here is an article on how to upload a file via FTP in .NET Framework v2.0
using FTPWebRequest and FTPWebResponse classes.
There may be more enhanced FTP functions in later versions of .NET Framework, but I am not sure of the specifics that you need to do.


Ya my ftp server need authentication.. i want to give ftp name, user name and password through asp.net to access all the content in that server.
this example is helpful for uploading file to ftp site. Get your stuff from here.

//C# Equivalent
using System.IO;
using System.Net;

namespace ftpupload
public class ftpupload

public void uploadFileUsingFTP(string CompleteFTPPath, string CompleteLocalPath, string UName, string PWD)
//Create a FTP Request Object and Specfiy a Complete Path
FtpWebRequest reqObj = (FtpWebRequest)WebRequest.Create(CompleteFTPPath);
//Call A FileUpload Method of FTP Request Object
reqObj.Method = WebRequestMethods.Ftp.UploadFile;
//If you want to access Resourse Protected You need to give User Name and PWD
reqObj.Credentials = new NetworkCredential(UName, PWD);
//FileStream object read file from Local Drive
FileStream streamObj = File.OpenRead(CompleteLocalPath);
//Store File in Buffer
byte[] buffer = new byte[streamObj.Length + 1];
//Read File from Buffer
streamObj.Read(buffer, 0, buffer.Length);
//Close FileStream Object Set its Value to nothing
//Upload File to ftp://localHost/ set its object to nothing
reqObj.GetRequestStream().Write(buffer, 0, buffer.Length);


could you help me to view and select the contents in ftp through asp.net page and select that files to download.
To get a directory listing of the FTP server's /pub directory:

Dim fullList As FtpDirectory = myFtp.GetDirectoryDetail("/pub/")


'Ftp.GetDirectoryDetail' this link not working
bcos you have to create an instance...

 create a new instance of the object, defining the host, username and password.

Dim myFtp As New FtpClient(hostname, username, password)
or you can use ListDirectoryDetails

I have another idea if you don't want your ASP page to delay rendering while doing the FTP transaction...  

Assuming you have permission to install software on your web server, you could install a Robo-FTP "hot send" service that watches a local folder for new files and then sends anything it finds to the remote FTP site.  This way, all your ASP has to do is put the uploaded file into the outgoing folder.  If you wanted to get fancy about it, you could configure the Robo-FTP command script to only send files of a certain size, type, filename etc.  If users log in to your web app you could put the uploaded file in a subfolder with the same name as the user and then set the service up to apply different filtering rules to files uploaded by different users.


No, i have not permission to install software or Download the software. But i have permission to access the webserver and that details. could you help me this site"ftp.sunfreeware.com " code in C#. i want to know and understand that code.  how is it works and functionality. I am Very new to FTP .
This one is on us!
(Get your first solution completely free - no credit card required)


Thanks Sanjithml. from that link i learnd more things.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.