/// <summary>   
        /// Test harness
        /// </summary>
        public static void Main(string[] args)
        {
            // we want remote host, user name and password
            if (args.Length < 7)
            {
                log.Debug(Convert.ToString(args.Length));
                Usage();
                System.Environment.Exit(1);
            }
            try
            {
                // assign args to make it clear
                string host = args[0];
                string user = args[1];
                string password = args[2];
                string filename = args[3];
                string directory = args[4];
                string mode = args[5];
                string connMode = args[6];

                FTPClient ftp = new FTPClient();
                ftp.RemoteHost = host;
                ftp.ControlPort = 21;

                // set up message collector
                ftp.CommandSent += new FTPMessageHandler(FTPClientTest.LogCommand);
                ftp.ReplyReceived += new FTPMessageHandler(FTPClientTest.LogReply);
                ftp.TransferStarted += new EventHandler(FTPClientTest.LogTransferStarted);
                ftp.TransferComplete += new EventHandler(FTPClientTest.LogTransferComplete);

                // connect
                ftp.Connect();
                ftp.Login(user, password);
                ftp.Quit();

                // connect again
                ftp = new FTPClient(host);
                ftp.CommandSent += new FTPMessageHandler(FTPClientTest.LogCommand);
                ftp.ReplyReceived += new FTPMessageHandler(FTPClientTest.LogReply);
                ftp.TransferStarted += new EventHandler(FTPClientTest.LogTransferStarted);
                ftp.TransferComplete += new EventHandler(FTPClientTest.LogTransferComplete);
                ftp.BytesTransferred += new BytesTransferredHandler(FTPClientTest.BytesTransferred);

                ftp.Login(user, password);

                // binary transfer
                if (mode.ToUpper().Equals("BINARY".ToUpper()))
                {
                    ftp.TransferType = FTPTransferType.BINARY;
                }
                else if (mode.ToUpper().Equals("ASCII".ToUpper()))
                {
                    ftp.TransferType = FTPTransferType.ASCII;
                }
                else
                {
                    log.Debug("Unknown transfer type: " + args[5]);
                    System.Environment.Exit(- 1);
                }

                // PASV or active?
                if (connMode.ToUpper().Equals("PASV".ToUpper()))
                {
                    ftp.ConnectMode = FTPConnectMode.PASV;
                }
                else if (connMode.ToUpper().Equals("ACTIVE".ToUpper()))
                {
                    ftp.ConnectMode = FTPConnectMode.ACTIVE;
                }
                else
                {
                    log.Debug("Unknown connect mode: " + args[6]);
                    System.Environment.Exit(- 1);
                }

                // change dir
                ftp.ChDir(directory);

                // Put a local file to remote host
                ftp.Put(filename, filename);

                // get bytes
                byte[] buf1 = ftp.Get(filename);
                log.Debug("Got " + buf1.Length + " bytes");

                // append local file
                try
                {
                    ftp.Put(filename, filename, true);
                }
                catch (FTPException ex)
                {
                    log.Debug("Append failed: " + ex.Message);
                }

                // get bytes again - should be 2 x
                //byte[] buf2 = ftp.Get(filename);
                //log.Debug("Got " + buf2.Length + " bytes");

                // rename
                ftp.Rename(filename, filename + ".new");

                // get a remote file - the renamed one
                ftp.Get(filename + ".tst", filename + ".new");

                // delete the remote file
                ftp.Delete(filename + ".new");

                // ASCII transfer
                ftp.TransferType = FTPTransferType.ASCII;

                // test that dir() works in full mode
                string[] listings = ftp.Dir(".", true);
                for (int i = 0; i < listings.Length; i++)
                    log.Debug(listings[i]);

                // and now DirDetails test
                FTPFile[] files = ftp.DirDetails(".");
                log.Debug(files.Length + " files");
                for (int i = 0; i < files.Length; i++) {
                    log.Debug(files[i].ToString());
                }

                // try system()
                log.Debug(ftp.GetSystem());

                // try pwd()
                log.Debug(ftp.Pwd());

                ftp.Quit();

                log.Debug("******** message log ********");
                log.Debug(FTPClientTest.messages.ToString());
            }
            catch (SystemException ex)
            {
                log.Debug("Caught exception: " + ex.Message);
            }
            catch (FTPException ex)
            {
                log.Debug("Caught exception: " + ex.Message);
            }
        }