Rob Sedgwick
Rob Sedgwick

Reputation: 4514

FtpWebRequest ListDirectory truncated at 10,000 files

I am trying to get an FTP directory listing. I have more than 10,000 files in my folder and it seems that the list I get back is truncated at 10,000 files. Is there anything I can do so that I can get all the files back?

FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://mysite.com");
request.Method = WebRequestMethods.Ftp.ListDirectory;

request.Credentials = myCache;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();

Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
string Datastring = reader.ReadToEnd();

string[] myfiles = Datastring.Split(new string[] { Environment.NewLine },
    StringSplitOptions.RemoveEmptyEntries);

Upvotes: 0

Views: 41

Answers (0)

Related Questions