Hi friends,
I need to view files and folders which is available in remote system directory using FTP connection. I established a connction to the remote system usign FTP. but i dont know how to view the files and folders as a tree structure format. that tree structure like.
-root directory
+sub directory
- subdirectory
-file
-file
if any one know the possible solutions please do let me know..
thanks,
regards
sasi
Loading
chirag shahPosted Oct 8, 2014, 2:27 PM
Were you able to find one for Web Application?
Thanks,
Chirag
Steve OmorPosted Sep 8, 2011, 3:22 PM
Zoran HorvatPosted Jul 26, 2011, 4:59 AM
Zoran
Sasikumar SPosted Jul 26, 2011, 3:54 AM
Zoran HorvatPosted Jul 25, 2011, 9:26 AM
Zoran
Sasikumar SPosted Jul 23, 2011, 10:02 AM
Zoran HorvatPosted Jul 22, 2011, 4:58 PM
Zoran
Sasikumar SPosted Jul 22, 2011, 1:36 PM
Zoran HorvatPosted Jul 22, 2011, 10:48 AM
If you're developing Windows Forms application, then solution which is based on the same FtpClient as in your previous post can be easily developed. I've appended ZIP containing source code for the form which lets you enter FTP address and credentials and it populates the TreeView control.
Basically, solution is in this function:
private void PopulateTreeViewRecursively(FTPclient cli, TreeNode parentNode)
{
string curDir = cli.CurrentDirectory;
FTPdirectory dirContent = cli.ListDirectoryDetail(curDir);
FTPdirectory subdirs = dirContent.GetDirectories();
Hashtable dirsVisited = new Hashtable();
foreach (FTPfileInfo file in subdirs)
{
dirsVisited.Add(file.Filename, null);
cli.CurrentDirectory = file.FullName;
TreeNode node = new TreeNode(file.Filename.ToUpper());
if (parentNode != null)
parentNode.Nodes.Add(node);
else
tvDirectories.Nodes.Add(node);
PopulateTreeViewRecursively(cli, node);
}
foreach (FTPfileInfo file in dirContent)
if (!dirsVisited.ContainsKey(file.Filename))
{
TreeNode node = new TreeNode(file.Filename);
if (parentNode != null)
parentNode.Nodes.Add(node);
else
tvDirectories.Nodes.Add(node);
}
if (parentNode != null)
parentNode.Expand();
}
This function is quite similar to the function which was printing nodes on Console, only this time data are added to the TreeView.
The project attached is created in Visual Studio 2008, but should be convertible to other versions of VS if needed.
Zoran
Zoran HorvatPosted Jul 22, 2011, 8:30 AM
Are you building Windows Forms or Web application?
Zoran
Jaganathan BantheswaranPosted Jul 22, 2011, 8:19 AM
I guess you are getting the collection of folders and files from FTP.
If so,
Look into this.