4 Replies - 10650 Views - Last Post: 31 May 2010 - 04:52 AM Rate Topic: -----

#1 Guest_HAHAHAHA*


Reputation:

Are you missing a using directive or an assembly reference?

Posted 31 May 2010 - 04:43 AM

Dear Programmers


I have encountered a problem where my programs keeps popping out this specific error Error The type or namespace name 'FTP' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\chiaw\Mes documents\Visual Studio 2008\Projects\Project environment variable\Project environment variable\Program.cs 18 30 Project environment variable


what could be the problem?



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


namespace Project_environment_variable
{
    class Program
    {
        static void Main(string[] args)
        {


            // create an instance of the ftp library

            FTP ftplib = new FTP();

            try
            {
                // there are server, user and password properties

                // that can be set within the ftplib object as well

                // those properties are actually set when

                // you call the Connect(server, user, pass) function

                ftplib.Connect("pc2405a.esiee.fr",
                               "anonymous",
                               "");
                //ftplib.ChangeDir("directory_foo/");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                int perc = 0;

                // open the file with resume support if it already exists, the last 

                // peram should be false for no resume

                ftplib.OpenDownload("license.txt", true);
                while (ftplib.DoDownload() > 0)
                {
                    perc = (int)((ftplib.BytesTotal * 100) / ftplib.FileSize);
                    Console.Write("\rDownloading: {0}/{1} {2}%",
                      ftplib.BytesTotal, ftplib.FileSize, perc);
                    Console.Out.Flush();
                }
                Console.WriteLine("File Downloaded");
            }
            catch (Exception ex)
            {
                Console.WriteLine("File not Downloaded");
                Console.WriteLine(ex.Message);
            }
        }
    }
}


This post has been edited by JackOfAllTrades: 31 May 2010 - 04:50 AM
Reason for edit:: Fixed code tags.


Is This A Good Question/Topic? 0

Replies To: Are you missing a using directive or an assembly reference?

#2 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 382
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: Are you missing a using directive or an assembly reference?

Posted 31 May 2010 - 04:47 AM

Your program is expecting to find a class named FTP, but is unable to find it... Is this FTP some external thing or you just might written it wrong. Try Ftp instead of FTP.
Was This Post Helpful? 0
  • +
  • -

#3 Skaggles  Icon User is offline

  • THE PEN IS MIGHTIER
  • member icon





Reputation: 251
  • View blog
  • Posts: 640
  • Joined: 01-March 09

Re: Are you missing a using directive or an assembly reference?

Posted 31 May 2010 - 04:48 AM

Where is the FTP class coming from? I'm not aware of one built into .NET other than FtpWebRequest.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,222
  • Joined: 23-August 08

Re: Are you missing a using directive or an assembly reference?

Posted 31 May 2010 - 04:50 AM

When posting code, use CODE tags, like this

:code:
Was This Post Helpful? 0
  • +
  • -

#5 Rico Diesel  Icon User is offline

  • D.I.C Head

Reputation: 62
  • View blog
  • Posts: 122
  • Joined: 06-May 10

Re: Are you missing a using directive or an assembly reference?

Posted 31 May 2010 - 04:52 AM

Hi guest,

The FTP object does not exist in the namespaces you are currently using.
This link describes the implementation of an FTP client in C#.

Hope this helps,

Rico

*EDIT* Wow, you guys are fast with replying...

This post has been edited by Rico Diesel: 31 May 2010 - 04:53 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1