Get A Full Directory Structure - WeOnlyDo Discussion board

Get A Full Directory Structure (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Darren, Monday, March 21, 2005, 10:55 (6987 days ago)

Hi

Can anybody point me in the right direction to get a full directory listing for an ftp server in VB6 including all paths and files ?

Im new to FTP scene and cant seem to sus this one out.

Thanks In Advance For Any Hep

Regards

Re: Get A Full Directory Structure

by wodSupport, Monday, March 21, 2005, 12:35 (6987 days ago) @ Darren

Darren,

there's no such common way to do it in FTP protocol (such as it would be, for example, ls -alR on UNIX systems), but I suggest you use LoopFiles method from root folder, in unlimited depth. LoopItem even will fire for each directory entry.

Would that help?

Re: Get A Full Directory Structure

by Peter, Tuesday, March 22, 2005, 02:56 (6986 days ago) @ wodSupport

Oh my hehe... I should have read the docs better! I just coded my own recursivity function.

I wonder what loopitems does however if parsing fails halfway on an FTP with 20000 or more folders, does it have to entirely restart or does it know where it left off?

For that reason, it can be good to have your own procedure, like this thing that I came up with: (error trapping must of course be added still)


You dim an array() and a counter
You put the startpath in the array

Array(1) = /startpath/

You start a nested for each loop:

counter = 1
For Each thing in Array()

objFTP.ListDir array(counter) '/ get dirlisting

for each item in DirItemsCollection() '/ wodftpdlx.diritems()
debug.print item.name '/ display item (dir or file)
if item.type = directory then '/ populate array with dirs to CWD to
counter = counter + 1
Array(counter) = item.Name '/ only dirs are put here
next item

Next thing

Or you can use the ListItems event, to extract your data from after listing the initial path.

Re: Get A Full Directory Structure

by Peter, Tuesday, March 22, 2005, 02:59 (6986 days ago) @ Peter

My 'fantasy' code has some errors in it but i'm sure you'll spot them, the idea is what counts.

Re: Get A Full Directory Structure

by wodSupport, Wednesday, March 23, 2005, 01:56 (6985 days ago) @ Peter

I wonder what loopitems does however if parsing fails halfway on an FTP with 20000 or more folders, does it have to entirely restart or does it know where it left off?

Nope, it doesn't know where it have stopped.

I think your implementation is better for what you need - recursive calls to ListDir, so stick with it. Firing LoopItem even 20000 times is not a good idea, anyway :)