CPSRI
asked on
Connecting to FTP
Hi,
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
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
ASKER
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.
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...
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
http://www.devasp.net/net/articles/display/280.html
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.
Here is an article on how to upload a file via FTP in .NET Framework v2.0
http://www.devasp.net/net/articles/display/280.html
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.
ASKER
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(Com pleteFTPPa th);
//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(CompleteLoca lPath);
//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
streamObj.Close();
//Upload File to ftp://localHost/ set its object to nothing
reqObj.GetRequestStream(). Write(buff er, 0, buffer.Length);
}
}
}
//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.
//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(CompleteLoca
//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
streamObj.Close();
//Upload File to ftp://localHost/ set its object to nothing
reqObj.GetRequestStream().
}
}
}
ASKER
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/")
Dim fullList As FtpDirectory = myFtp.GetDirectoryDetail("/pub/")
ASKER
'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)
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.
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.
ASKER
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 .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Sanjithml. from that link i learnd more things.
let me know.