943,719 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 3625
  • C# RSS
Jan 9th, 2009
0

FTP Server Directory Treeview

Expand Post »
Just because there is no help for this online that i could find, I'm posting this for all the other coders...

This makes use of a third part class downloaded from code project... AWESOME FTP class this , i owe the creators a huge thank you ...

C# Syntax (Toggle Plain Text)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Data.Sql;
  8. using System.Data.SqlClient;
  9. using System.Data.OleDb;
  10. using System.Windows.Forms;
  11. using System.IO;
  12. using System.Net.Mail;
  13. using System.Net;
  14. using System.Net.Mime;
  15. using System.Web;
  16. using System.IO.Compression;
  17. using Microsoft.Win32;
  18. using System.Net.Sockets;
  19. using System.Runtime;
  20.  
  21.  
  22. namespace TestDummyTWO
  23. {
  24. public partial class Form1 : Form
  25. {
  26. FTPLib.FTP FTPLIB = new FTPLib.FTP();
  27.  
  28. public Form1()
  29. {
  30. InitializeComponent();
  31. }
  32.  
  33. private void Form1_Load(object sender, EventArgs e)
  34. {
  35.  
  36. /* THIS IS THE FORMULA
  37.   * TreeNode MyNodeMain = new TreeNode();
  38.   * TreeNode MyNodeChild = new TreeNode();
  39.   * MyNodeMain.Text = "Main";
  40.   * MyNodeChild.Text = "child";
  41.  
  42.   * mytree.Nodes.Add(MyNodeMain);
  43.   * MyNodeMain.Nodes.Add(MyNodeChild);
  44.   */
  45.  
  46.  
  47.  
  48. FTPLIB.server = "******";
  49. FTPLIB.user = "*******";
  50. FTPLIB.pass = "******";
  51.  
  52. foreach (string S in FTPLIB.ListDirectories())
  53. {
  54. /* Making parent node */
  55. TreeNode ParentNode = new TreeNode();
  56. ParentNode.Text = S.Substring(55);
  57. treeView1.Nodes.Add(ParentNode);
  58.  
  59. /* Making child node */
  60.  
  61. FTPLIB.ChangeDir("//" + S.Substring(55) + "/");
  62. foreach (string S2 in FTPLIB.List())
  63. {
  64. FTPLIB.ChangeDir("//" + S.Substring(55) + "/");
  65.  
  66. TreeNode ChildNode = new TreeNode();
  67. ChildNode.Text = S2.Substring(55);
  68. ParentNode.Nodes.Add(ChildNode);
  69.  
  70. FTPLIB.ChangeDir(".");
  71. }
  72.  
  73. }
  74. }
  75. }
  76. }

Happy coding people , code is shibby ....
Last edited by cVz; Jan 9th, 2009 at 9:38 am.
Similar Threads
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Jan 9th, 2009
0

Re: FTP Server Directory Treeview

lets pray the ftp servers you use always return exactly the same format in each line then, and that they dont have longer filenames, or usernames or longer/shorter permissions.

However, builing a tree view of something is generally an easy enough concept, and your treeview only allows 1 level, its not recursive.. but, its good you got there in the end.

Btw, shouldnt
C# Syntax (Toggle Plain Text)
  1. FTPLIB.ChangeDir(".");
be a little pointless as you are changing to a fully qualified path each time. and "." means dont change.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Jan 9th, 2009
0

Re: FTP Server Directory Treeview

Quote ...
FTPLIB.ChangeDir(".");
Takes you to the root folder again, this is just an example , i mean surely every person has a brain to take this code and play around with it ... i just wanted to help man ... seriously....

Its the theory you see there, i just gave an example , one can use this in small applications ... (i hate the treeview though, might do it with a listview....) but we already played with that hehehe

Thanks for all your help man , I'm finally finding some structure in my application to work with ...
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Jan 9th, 2009
0

Re: FTP Server Directory Treeview

I guess you could just use
C# Syntax (Toggle Plain Text)
  1. FTPLIB.ChangeDir("//");
or something, on my server the previous folder is the "."-dir so going there takes you back back back ... cool navigation i tell you ...
Last edited by cVz; Jan 9th, 2009 at 10:32 am.
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Jan 9th, 2009
0

Re: FTP Server Directory Treeview

Thats very unusual. On every other OS in the world, "." is current folder, including windows and unix.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Nov 20th, 2009
0
Re: FTP Server Directory Treeview
I am using print directory on My Computer or Windows Explorer, To print information about all your files. Print Directory can print the name of every file on a drive, along with the file's size, date and time of last modification, and attributes (Read-Only, Hidden, System and Archive)! And now, the list of files can be sorted by name, size, date.

Download Free : http://www.print-directory.com
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Pinos is offline Offline
1 posts
since Nov 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Can you help with c# again.
Next Thread in C# Forum Timeline: face localization in an image





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC