FTP Server Directory Treeview

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 135
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 7
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

FTP Server Directory Treeview

 
0
  #1
Jan 9th, 2009
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 ...

  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.
Delphi & C# programmer deluxe...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: FTP Server Directory Treeview

 
0
  #2
Jan 9th, 2009
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
  1. FTPLIB.ChangeDir(".");
be a little pointless as you are changing to a fully qualified path each time. and "." means dont change.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 135
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 7
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: FTP Server Directory Treeview

 
0
  #3
Jan 9th, 2009
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 ...
Delphi & C# programmer deluxe...
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 135
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 7
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: FTP Server Directory Treeview

 
0
  #4
Jan 9th, 2009
I guess you could just use
  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.
Delphi & C# programmer deluxe...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: FTP Server Directory Treeview

 
0
  #5
Jan 9th, 2009
Thats very unusual. On every other OS in the world, "." is current folder, including windows and unix.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 1
Reputation: Pinos is an unknown quantity at this point 
Solved Threads: 0
Pinos Pinos is offline Offline
Newbie Poster
 
0
  #6
3 Days Ago
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
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC