IT Community - Software Programming, Web Development and Technical Support

How to access files and folders inside a ftp site?

This is a discussion on How to access files and folders inside a ftp site? within the C# Programming forums, part of the Software Development category; Does anybody know how to access the files and folders given a ftp site,user name and password details to ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-20-2007, 12:46 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Exclamation How to access files and folders inside a ftp site?

Does anybody know how to access the files and folders given a ftp site,user name and password details to login the site?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-23-2007, 03:39 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 299
Karpagarajan is on a distinguished road
Thumbs up Re: How to access files and folders inside a ftp site?

Hi..

Here I have given the sample code for FTP file download. It will help you to implement the FTP file functionality in your C#.

// Set up the request

FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(downloadUri);

// use the provided credentials
if (this._isAnonymousUser == false)
{
ftpRequest.Credentials = new NetworkCredential(this._userName, this._password);
}


// Download a file. Look at the other methods to see all of the potential FTP features

ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile;

// get the response object

FtpWebResponse ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();


Stream stream = null;
StreamReader reader = null;
StreamWriter writer = null;


// get the file as a stream from the response object and write it as
// a file stream to the local PC


try
{
stream = ftpResponse.GetResponseStream();
reader = new StreamReader(stream, Encoding.UTF8);

writer = new StreamWriter(destinationFile, false);
writer.Write(reader.ReadToEnd());

return ftpResponse.StatusCode;
}
finally
{
// Allways close all streams

stream.Close();
reader.Close();
writer.Close();
}


Hope it will help you to manage the FTP file. If anything else let me know

thanks
__________________
Karpagarajan. R
Necessity is the mother of invention

Last edited by Karpagarajan : 03-23-2007 at 03:43 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-24-2007, 01:08 AM
Anandavinayagam Anandavinayagam is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 131
Anandavinayagam is on a distinguished road
Default Re: How to access files and folders inside a ftp site?

Sathish I have doubt in ur Question

Do u want to access means download/Upload

or

View the list of files in FTP server
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-24-2007, 12:54 PM
echos echos is offline
D-Web Trainee
 
Join Date: Mar 2007
Posts: 37
echos is on a distinguished road
Thumbs up Re: How to access files and folders inside a ftp site?

Good advice Karpagarajan. Thankx, it helped me.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-02-2007, 07:29 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Default Re: How to access files and folders inside a ftp site?

I have implemented the FTP download and Upload.Thanks for ur advice.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limit on Sub-folders / Files in Linux bluesky Operating Systems 5 03-31-2008 11:03 PM
Cant access Sharepoint Site on port 80 arjkhanna Server Management 2 01-31-2008 08:36 AM
i want create one web site and same site to work multiple language how is possible ? vel.m8 ASP and ASP.NET Programming 1 11-15-2007 01:58 AM
Can we have a commit statement inside a trigger? if no why cant we? Mramesh Database Support 6 09-11-2007 03:08 AM
Access e-mail using Outlook Web Access gattuso Server Management 0 07-19-2007 07:20 AM


All times are GMT -7. The time now is 08:49 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0