Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Populate tree view with remote computer directories

treeview tcpclient directory populate remote treenode

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 spreadzz

spreadzz

    CC Lurker

  • New Member
  • Pip
  • 7 posts

Posted 19 November 2012 - 09:46 AM

I want to make an Explorer to view folders from a remote computer using the TcpClient
Dose anyone have any solutions ?
The method i apropched is that on the server side i made that when i send the string "DirectoryInfo path" the server launches DirectoryInfo mypath returns the folders in a string and sends them back using NetworkStream, then i read the stream an add them to the treevies using a very raw and ** method ex:

TreeNode hdd1 = new TreeNode(@"C:\");
string[] folder =Regex.Split("return string from netStream", "\r\n");
foreach (string fd in folder)
{
hdd1.Nodes.Add(fd);
}
treeView1.Nodes.Add(hdd1);


and that is how i get the first folders in "C:\", as you can see it is a primitive method, any ideas on how can i do this cleaner ? or how to get the next subfolders and so on, or at least improve my code?
Thanks in advance.

#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 20 November 2012 - 12:56 AM

I will give you a hint : Your hint is here ( for directory to treeview )

about your code, the c: will be a problem, since most of computers has many disc units and usually c: is only for programs and installations.
If you want to open the sub-directory's branches you are going to need a recursive method that splits the path by \

#3 spreadzz

spreadzz

    CC Lurker

  • New Member
  • Pip
  • 7 posts

Posted 23 November 2012 - 09:09 AM

I know how to recursivelly add directories and subdirectories to a TreeView, i did not know how to send the info over TCP. But i found a way.

I add directories to a TreeNode then use BinaryFormatter to serialize it and on the reciveing side the BinaryFormatter to deserialize it and add it to the TreeView




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download