FTP Question

03-26-2002, 09:50 AM
I want to create a simple FTP program and so far I can access and display the files in a text box. Is there an easy way to display the file & folders in a tree view? So I can navigate and copy & send files?


03-26-2002, 09:53 AM
You might learn some tricks form VolteFace's Listview File Explorer (http://visualbasicforum.com/showthread.php?s=&threadid=19580) and see how you can adapt it to suit a full file treeview instead. I suggest you download the last one on the page, #3.


03-26-2002, 09:55 AM
It can be done, but easy? The treeview is a fairly tricky control with a lot of options. You have to create a node for each file and subdirectory. When a user clicks on a node, you either do something with the file (if he clicked on a file) or open the sub directory (if she clicked on a subdir) and attach new files/subdirectories as child nodes of the parent.

03-26-2002, 11:42 AM
But what would be the simplest way to display the files & folders in a tree or browser type thing?

03-26-2002, 11:54 AM
You can execute a "dir" command and loop until you stop getting data. Start at the highest directory execute the "dir" command and recursively work you way through the file system.

03-26-2002, 12:48 PM
the dir command is a bit confusing, I was kinda hoping there was an easier way to display the files & folders. What good is using this control if you can't view all files? You actually have to know the name and path of the file you want to up or dowl load..Kinda useless no?

03-26-2002, 12:58 PM
No...When you you use the dir command it send back everything in the current directory. That is how you display the files/folder on the remote machine. You can then use the File System Object to get all files on the local machine. Go to google.com and do a search on "FTP" + "VB". I know there a few nice people out there that share there source code to accomplish exactly what you are looking to do. I think MSDN also has that exact example in it.
If I find my source code for this program I will attach it.

03-26-2002, 01:00 PM
Thanks for the help, I know it's not a problem to retrieve the dir tree for the local comp, but when I retrieve the data on the server, it is all contained in 1 string. Do I have to break it apart and find where folders are?

03-26-2002, 01:15 PM
That is why you need to recursively go through the file system. I recommend getting the needed data on the fly though. Meaning if someone clicks on a directory then go out and execute a "dir" on that directory. It would be a waste to go out and get the entire file system. Get the information you need on a need to know basis only.
When my program started I executed a "dir" on the root (c:\) directory. I then displayed all the subdirectories off of root in a list box. If I clicked on one of those subdirectories the program then went out and executed a "dir" on that directory and so on.
That should make it easier. To get all the information you are going to need the getchunk method (assuming you are usine the internet transfer control)

here is how the getchunk method works

itcFTP.Execute "ftp.microsoft.com", "pwd"
lblRemoteDirectory.Caption = itcFTP.GetChunk(1024, icString)

Good Luck

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum