none
In FTPS server using C# code i can't able to list the full files RRS feed

  • Question

  • IN ftp server directory having nearly 4000 files but i can list 510 files only,(implicit over TLS security) can any help me to list the full files from dir....

    here is my code

    // try
                    {
                        /* Create an FTP Request */
                        ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + directory);
                        /* Log in to the FTP Server with the User Name and Password Provided */
                        ftpRequest.Credentials = new NetworkCredential(user, pass);
                        /* When in doubt, use these options */
                        ftpRequest.UseBinary = true;
                        ftpRequest.UsePassive = true;
                        ftpRequest.KeepAlive = true;
                        ftpRequest.EnableSsl = true;
                    //    X509Certificate x = new X509Certificate();
                        ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
                        /* Specify the Type of FTP Request */
                        ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
                        /* Establish Return Communication with the FTP Server */
                        ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
                        /* Establish Return Communication with the FTP Server */
                        ftpStream = ftpResponse.GetResponseStream();
                        /* Get the FTP Server's Response Stream */
                        StreamReader ftpReader = new StreamReader(ftpStream);
                        /* Store the Raw Response */
                        string directoryRaw = null;
                        /* Read Each Line of the Response and Append a Pipe to Each Line for Easy Parsing */
                        try { while (ftpReader.Peek() != -1) { directoryRaw += ftpReader.ReadLine() + "|"; } }
                        catch (Exception ex) { }
                        /* Resource Cleanup */
                        ftpReader.Close();
                        ftpStream.Close();
                        ftpResponse.Close();
                        ftpRequest = null;
                        /* Return the Directory Listing as a string Array by Parsing 'directoryRaw' with the Delimiter you Append (I use | in This Example) */
                        try { string[] directoryList = directoryRaw.Split("|".ToCharArray()); return directoryList; }
                        catch (Exception ex) { Console.WriteLine(ex.ToString()); }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                      
                       
                    }
                    //

    Monday, October 20, 2014 10:54 AM

Answers

  • 1) Consider use List<string>instead of using "+="  with separator on string then splitting it.
    2) Try use write a program to generate numeric only filenames on FTP server and get it there to see if the number of file get can reach higher number, it may have choked on character set.
    3) Check the settings of FTP server. Some FTP server (such as ProFTPD) may limit the number of files displayed by LIST command.

    If there are actually error message returned by server, it'd be helpful to post here to let us know too.

    Tuesday, October 21, 2014 1:58 AM
    Answerer