+1 vote

Please bear with a newby!!! This is the first time using any program to FTP. I am attempting to use C#. Even though the Mail.dll worked without a problem, I cannot get past the first line of the example...

using (Ftp client = new Ftp())

It immediately shows as error (Invalid token 'using' in class, struct, or interface member declaration) and it does not recognize 'client' as being declared. I have tried numerous ways to declare it without success. It also complains about the '(' as being invalid tokens.

by (1.3k points)
What language are you using C# or VB.NET?
I am using C# and have the 'using Limilabs.FTP.Client;' with the using statements.

1 Answer

+1 vote
 
Best answer

You must declare a class first. This is how a sample console application, that uploads a file using FTP, would look like:

using System; 
using Limilabs.FTP.Client; 

class Program 
{ 

    static void Main(string[] args) 
    { 
        using(Ftp ftp = new Ftp())
        {
            ftp.Connect("ftp.server.com");  // or ConnectSSL for SSL
            ftp.Login("user", "password");

            ftp.ChangeFolder("uploads");
            ftp.Upload("report.txt", @"c:\report.txt");

            ftp.Close();
        }
    } 
}; 
by (297k points)
selected by
The class was declared, however your answer did fix the current problem as I did not have the procedure

static void Main(string[] args)

in the code.  Thank you for your swift reply!
...