User (Old forums)MemberSeptember 30, 2004 at 2:32 amPost count: 23064
How would one go about filtering all files out [b]*EXCEPT*[/b] a file provided to the ListFolderContents method? Basically I want to retrieve all remote folders and only files that match a certain query (whatever.xml for instance).
I’m also curious how I can interpret if a return item is a folder or a file, so I can create a mini-ftp browser. I will be honest – I haven’t read all of the docs yet and this may be very obvious in them – I just haven’t had the time to do so yet. Thanks for any help. 🙂
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Nick_N (had 5450 views)User (Old forums)MemberSeptember 30, 2004 at 2:34 amPost count: 23064
Heh – whoops. Normal BB code no workie ([b][/b]). Doesn’t look like I can edit my post either. My bad. 🙁
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Nick_N (had 369 views)User (Old forums)MemberSeptember 30, 2004 at 10:27 amPost count: 23064
You mention “ListFolderContents”, but that’s a method of the ActiveX version of Xceed FTP. Before I answer, can you confirm you’re using Xceed FTP for .NET, and you mean “GetFolderContents”? Else, simply resubmit your question to the <A href=”http://www.xceedsoft.com/Forums/ShowForum.aspx?ForumID=16″>Xceed FTP ActiveX forum</A>, and I’ll follow up.
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Martin (had 243 views)User (Old forums)MemberSeptember 30, 2004 at 3:49 pmPost count: 23064
Right – I apologize. I am definately using the .NET version. I had the wrong doc open obviously. I’d be using GetFolderContents.
Sorry for the confusion.
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Nick_N (had 403 views)User (Old forums)MemberOctober 1, 2004 at 11:31 amPost count: 23064
GetFolderContents does not list folder contents recursively. You will need to implement it yourself. I can show you some code if you wish. But if your primary goal is to download those files, you can call <A href=”http://doc.xceedsoft.com/products/ftpNet/ref/xceed.ftp.ftpclient.receivemultiplefiles.html”>ReceiveMultipleFiles</A> right away and skip the listing part, as the ReceiveMultipleFiles does support recursive download. You would simply do this:
client.ReceiveMultipleFiles( “whatever.xml”, @”d:\localpath”, true, true );
Obviously, you need to also set “recreateFolderStructure” to true to avoid overwriting each file with the next.
If you only need to list recursively, simply reply, and I’ll post some code.
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Martin (had 263 views)User (Old forums)MemberOctober 4, 2004 at 5:59 pmPost count: 23064
It would be nice to list recursivly – so I can apply the data to a treeview all at one time. 🙂 If you have time to post the code – that would be awesome. *thumbup*
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Nick_N (had 431 views)User (Old forums)MemberOctober 5, 2004 at 10:27 amPost count: 23064
Here is some code that lists an FTP folder recursively.
<code> private static void RecursiveListFolderContents( FtpClient client, string mask )
string currentFolder = client.GetCurrentFolder();
if( !currentFolder.EndsWith( System.IO.Path.DirectorySeparatorChar.ToString() ) )
currentFolder += System.IO.Path.DirectorySeparatorChar;
FtpItemInfoList items = client.GetFolderContents( mask );
foreach( FtpItemInfo item in items )
Console.WriteLine( currentFolder + item.Name );
if( ( item.Type == FtpItemType.Folder ) || ( item.Type == FtpItemType.Link ) )
client.ChangeCurrentFolder( item.Name );
// The item is not a folder, or you do not have rights to list. We ignore
// the exception and continue with next item.
// Here, you know item is a folder, so you can add it to your treeview.
RecursiveListFolderContents( client, mask );
client.ChangeCurrentFolder( currentFolder );
However, I must take the opportunity to advise you not to fill a TreeView recursively like that. First, if the FTP server has many subfolders, this will take some time, and your application will look frozen. Second, collapsing and expanding a node won’t refresh the subnodes. If something changes on the other side, your app won’t notice, as it will have taken a snapshot at a specific moment.
I’m a fan of dynamically updating TreeViews and ListViews based on expanding/collapsing/selecting. I suggest you take a look at the ClientFtp sample, which uses a TreeView and a ListView to display folders and files. The general idea is to insert a dummy node in each folder node, and when about to expand it, you remove the dummy node, and actually list the folder contents (only child items, obviously).
Hope this helps.
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Martin (had 6228 views)
- You must be logged in to reply to this topic.