View Single Post
Join Date: Mar 2008
Posts: 134
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