c# - How to get only list of Folder name in FTP? -


how list of folder name of ftp not files names of folder,suppose have 4 folder (a,b,c,d) want 4 folder name not files ? working in c#.

i have seen code gives list of files .

i have tried code , giving me files name folder name, need folders name only.

regards haider

try this

string htmlresult = string.empty; console.writeline("starting listing of files...."); ftpwebrequest request = (ftpwebrequest)webrequest.create(properties.settings.default.ftpurl); request.credentials = new networkcredential(properties.settings.default.ftpusername, properties.settings.default.ftppassword); request.usepassive = false; request.method = webrequestmethods.ftp.listdirectorydetails; ftpwebresponse response = (ftpwebresponse)request.getresponse(); using (stream responsestream = response.getresponsestream()) {     using (streamreader reader = new streamreader(responsestream))     {         string _line = reader.readline();         while (_line != null && _line != string.empty)         {             htmlresult += _line;             _line = reader.readline();         }     }                     } //parse html output htmlagilitypack.htmldocument doc = new htmlagilitypack.htmldocument(); doc.loadhtml(htmlresult); foreach (htmlagilitypack.htmlnode node in doc.documentnode.selectnodes("//a[@href]")) {     if(node.innertext.contains(".txt")) ftplisting.add(node.innertext); } console.writeline("{0} files found", ftplisting.count); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -