Solved

server file and directory list

Posted on 2004-04-23
6
143 Views
Last Modified: 2010-05-02
i have a dedicated server that i connect to via ftp to upload and download my websites.

over time i have accumulated over 10000 pages in many different directories.

is there a way that i could write a program that ftps into my server and writes to a text file every filename and folder that its in?

i have found many examples of ftp code but i don't know how i would extract all the info into a file
0
Comment
Question by:Marcusw
  • 2
6 Comments
 
LVL 11

Expert Comment

by:jmwheeler
ID: 10900754
I imagine you could work with fso.  Add a reference to 'Microsoft Scripting Runtime' in your project and try this:

'This will create a text file listing every file and folder on a persons C: drive.  You will need to tweak it to work for ftp.  Somehow you will need to link svr to the server and not to the
'hard drive also fldr will need to be set to the root folder you want start with.
'Set svr = fso.GetDrive("C:\")     should need to be something like   Set svr = fso.GetDrive("\\ServerName\Whatever\")
'Set fldr = fso.GetFolder("C:\")

Option Explicit

Private fso As FileSystemObject
Private svr As Drive
Private fldr As Folder
Private fldr2 As Folder
Private fldr3 As Folder
Private fl As File

Private Sub Form_Load()
    Open "C:\OutputFile.txt" For Output As #1

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set svr = fso.GetDrive("C:\")
    Set fldr = fso.GetFolder("C:\")
   
    Print #1, "C:\"
    For Each fl In fldr.Files
        Print #1, vbTab & fl.Name
    Next
   
    For Each fldr2 In fldr.SubFolders
        Print #1, fldr2.Path
        GetFiles fldr2
    Next
   
    Close #1
    MsgBox ("Finished")
End Sub

Private Sub GetFiles(fldr2 As Folder)
    For Each fl In fldr2.Files
        Print #1, vbTab & fl.Name
    Next
   
    For Each fldr3 In fldr2.SubFolders
        Print #1, fldr3.Path
        GetFiles fldr3
    Next
End Sub
0
 

Author Comment

by:Marcusw
ID: 10919606
thanks jim i am having trouble with your code though, every time i try to run it as is it produces the following error

user defined type not defined

and highlights

Private Sub GetFiles(fldr2 As Folder)

any ideas
0
 

Author Comment

by:Marcusw
ID: 10947190
ive sorted the problem but i cannot get it to connect to my server, could anybody give me the code to connect with thanks
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11447661
PAQed, with points refunded (400)

Netminder
Site Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question