Subject: Cannot send command to the server because the response for previous one was not received
Date: 2013-09-15 07:21:32
From: Magnus Modig
Source: cannot-send-command-server-response-previous-one-not-received
----------------------------------------------------------------------

Hi

 

I use the following code to download files from a ftp server

[code lang='c#']
 


            // Create a new Ftp instance.
            var client = new Ftp();

            try
            {


                // Connect to the FTP server.
                client.Connect(FtpServer, FtpPort);
                
                client.Passive = false;
                client.Timeout = 60000; // 1 minut innan timeout

                // Authenticate.
                client.Authenticate(UserName, PassWord);
                client.KeepAlive();

                // Let the Ftp class keeps the connection alive during transfer a large file.
                client.KeepAliveDuringTransfer = true;
                // Keep alive every 1 second.
                client.KeepAliveInterval = 1000;

                // Register an event handler.
                client.Progress += client_Progress;

                foreach (var f in ListOfFiles)
                {

                    CurrFileToFetch = f.FileName.ToString();

                    client.SetCurrentDirectory(f.FolderPath);

                    if (client.FileExists(f.FileName.ToString()))
                    {
                        try
                        {
                            client.DownloadFile(f.FileName.ToString(), DestinationFolder + f.FileName.ToString());
                        }
                        catch (Exception ioexp)
                        {
                            // IO error
                        }
                        
                    }
                    else
                    {

                        
                    }


                }

                // Disconnect.
                client.Disconnect();
            }
            catch (Exception exp)
            {

                FtpError += exp.Message.ToString();
            }
            finally
            {
                if (client.IsConnected)
                { client.Disconnect(); }
            }
            
            
[/code]    

 

 

But I often get this error message "Cannot send command to the server because the response for previous one was not received."  , why is that and how can I fix that?   

---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index