Click here to Skip to main content
16,004,587 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am trying to connect to a remote FTP Server using Visual Studio 2015 but I am not sure how to come about this.

What I have tried:

The article provided here for a simple ftp client application but it doesn't work in VS 2015. Please help. Thank you.

Ali
Posted
Updated 6-Sep-16 6:06am
Comments
Leo Chapiro 6-Sep-16 11:55am    
What exactly do you want to achieve: do you want to debug an application remotely?
Member 12723305 6-Sep-16 12:05pm    
I am going to parse files and move them from one folder to another on the FTP Server.
Member 12723305 6-Sep-16 16:03pm    
I am using .netCore RC2.

1 solution

Use the FtpWebRequest Class (System.Net)[^] - the link includes an example.
 
Share this answer
 
Comments
Member 12723305 6-Sep-16 12:07pm    
It gives an error on FtpWebRequest.
OriginalGriff 6-Sep-16 12:20pm    
And what error would that be?
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. So we can't see what you compiled, and we can't see what happened after that! You have to tell us these things...
Member 12723305 6-Sep-16 12:32pm    
Sorry about that

CS0246 The type or namespace name 'FtpWebRequest' could not be found (are you missing a using directive or an assembly reference?)

Here's my code

using System;
using System.IO;
using System.Net;
using System.Text;

namespace TCRSJobs.Jobs.FileImport.FTP
{
public class WebRequestGetExample
{
public static void Main()
{
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/");
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;

// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential("anonymous", "janeDoe@contoso.com");

FtpWebResponse response = (FtpWebResponse)request.GetResponse();

Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
Console.WriteLine(reader.ReadToEnd());

Console.WriteLine("Directory List Complete, status {0}", response.StatusDescription);

reader.Close();
response.Close();
}
}
}
OriginalGriff 6-Sep-16 12:50pm    
Did you read the error message? :laugh:
"are you missing a using directive or an assembly reference?"
You have the using line, so check your project references and make sure that system.dll is referenced. It should be by default, but...
Member 12723305 6-Sep-16 12:33pm    
Same goes for 'FtpWebResponse'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900