I have a "windows 10 pro" and a fresh install of "visual studio community edition 2015" installed.
I do a new project console application and call it ftptest then copy and paste the code from here:
https://msdn.microsoft.com/en-us/library/ms229716%28v=vs.110%29.aspx
using System;
using System.IO;
using System.Net;
namespace ftpcheck
{
public class Program
{
public void Main(string[] args)
{
// 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();
}
}
}
And try to build it just to see what it does.
I get a lot of:
CS0246 The type or namespace name 'FtpWebRequest' could not be found (are you missing a using directive or an assembly reference?)
CS0246 The type or namespace name 'NetworkCredential' could not be found (are you missing a using directive or an assembly reference?)
How can i add that missing reference?
If you take a look on msdn, you will see the reference that you have to add:
https://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest(v=vs.110).aspx
Namespace: System.Net
Assembly: System (in System.dll)
answered with a comment by hans passant:
My crystal ball says that you are using the wrong project template to get started. Use Visual C# > Windows > Classic Desktop > Console Application. And you somehow lost the static keyword on the Main() method. – Hans Passant Nov 26 '15 at 20:48
include: using System.Net; in your references section
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.