.net - C# listing directory via FTP receives dots only -
i try list files in 1 folder via ftp:
ftpwebrequest reqftp; //uri string - webhost.com/public_html/some_dir/myfolder reqftp = (ftpwebrequest)ftpwebrequest.create(new uri("ftp://" + ftpserverip + "/" + remotedir + "/" + folder)); reqftp.usebinary = true; reqftp.credentials = new networkcredential(ftpuserid, ftppassword); reqftp.method = webrequestmethods.ftp.listdirectory; reqftp.proxy = null; reqftp.keepalive = false; reqftp.usepassive = false; reqftp.timeout = 300000;//wait 5 min response = reqftp.getresponse(); reader = new streamreader(response.getresponsestream()); string line = reader.readline(); while (line != null) //line '.' here { if(line.length > 3) { line = line.split('/')[1]; result.append(line); result.append("\n"); line = reader.readline(); } } the connection seems ok, response gets:
statusdescription 150 connecting port 50058\r\n welcomemessage 230 ok. current restricted directory /\r\n but problem when read line single dot. while loop goes infinite.
i tried connect server , it's working fine. i'd appreciate advice.
the first entry in directory . = reference "this" directory.
and never passed read next entry within if block, never to.
the code should like:
while (line != null) { if (line.length > 3) { line = line.split('/')[1]; result.append(line); result.append("\n"); } line = reader.readline(); } though line.length > 3 condition seems suspicious on own. that's different question.
Comments
Post a Comment