Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > FTP Question


Reply
 
Thread Tools Display Modes
  #1  
Old 03-26-2002, 09:50 AM
Yzerman_19
Guest
 
Posts: n/a
Talking FTP Question


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?

Thanks...
Reply With Quote
  #2  
Old 03-26-2002, 09:53 AM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

You might learn some tricks form VolteFace's Listview File Explorer 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.

__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #3  
Old 03-26-2002, 09:55 AM
BillSoo's Avatar
BillSoo BillSoo is offline
Code Meister

Retired Moderator
* Guru *
 
Join Date: Aug 2000
Location: Vancouver, BC, Canada
Posts: 10,441
Default

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.
__________________
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
Reply With Quote
  #4  
Old 03-26-2002, 11:42 AM
Yzerman_19
Guest
 
Posts: n/a
Default ok then,

But what would be the simplest way to display the files & folders in a tree or browser type thing?
Reply With Quote
  #5  
Old 03-26-2002, 11:54 AM
d_hadzima
Guest
 
Posts: n/a
Default

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.
D
Reply With Quote
  #6  
Old 03-26-2002, 12:48 PM
Yzerman_19
Guest
 
Posts: n/a
Talking I'll try

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?
Reply With Quote
  #7  
Old 03-26-2002, 12:58 PM
d_hadzima
Guest
 
Posts: n/a
Default

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.
D
Reply With Quote
  #8  
Old 03-26-2002, 01:00 PM
Yzerman_19
Guest
 
Posts: n/a
Default thanks

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?
Reply With Quote
  #9  
Old 03-26-2002, 01:15 PM
d_hadzima
Guest
 
Posts: n/a
Default

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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->