Results 1 to 8 of 8

Thread: map read

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Hengelo
    Posts
    61

    Question map read

    Hello every one,

    I have a question ,

    I must make a program that runs between 2 computers, (a laptop, and a Network drive)

    And the program must check, if files are old on the server or laptop so they can be overritten by the files on the server on the laptop or reverse!!

    The stucture from the Directory tree is the same, but how do i read in all the files in the differant, directory's and sub directory's??
    Does anyone know a loop for that?
    Maybe with an array??


    Thanks!! greetings CYbercool

  2. #2
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    I thought that I had already posted this for you..... but it doesn't seem to be in the forum anymore:

    This uses the FSO, and so needs a reference to Microsoft Scripting Runtime:
    VB Code:
    1. Private Sub Command3_Click()
    2.     ListFolder "C:\Temp\"
    3. End Sub
    4.  
    5. Private Sub ListFolder(sFolderPath As String)
    6.     Dim FS As New FileSystemObject
    7.     Dim FSfile
    8.     Dim FSfolder As Folder
    9.     Dim subfolder As Folder
    10.    
    11.     Set FSfolder = FS.GetFolder(sFolderPath)
    12.     'Add files to the list:
    13.     MsgBox "Looking in " & FSfolder
    14.     For Each FSfile In FSfolder.Files
    15.         '
    16.         '... e.g. List1.AddItem FSfile
    17.         '
    18.     Next FSfile
    19.  
    20.     For Each subfolder In FSfolder.SubFolders
    21.             Call ListFolder(subfolder.Path)
    22.     Next subfolder
    23.     Set FSfolder = Nothing
    24. End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Hengelo
    Posts
    61
    That does not work!!

  4. #4
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    It certainly does work here!
    Where are you having problems?


    Have you just cut and pasted the code? Or did you read it to realise that this line:
    VB Code:
    1. '... e.g. List1.AddItem FSfile
    had to be changed??
    You can change this line to:
    MSGBOX FSfile
    or
    List1.AddItem FSfile
    or anything else that you need to track all the files that you have in all your sub-directories.


    Similarly, the first line (ListFolder "C:\Temp\") will need changing so that you start from a particular point.


    Of course, you might be having problems with :
    This uses the FSO, and so needs a reference to Microsoft Scripting Runtime:

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Hengelo
    Posts
    61
    my problems are in here:
    Dim FS As New FileSystemObject
    Dim FSfile
    Dim FSfolder As Folder
    Dim subfolder As Folder

  6. #6
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    Have you added the reference that you need?

    See the last line of my previous post.

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Hengelo
    Posts
    61
    there are mistakes in the declaration, i think
    They do not match, with whats in the list!!!

  8. #8
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    IF you have a vali reference to the FSO (Mirosoft Scripting Runtime) in your References under the Project menu.
    AND
    IF you have cut and pasted the code correctly.

    THEN

    the only other thing I can think of is that you are using a different version of Visual Basic.

    'cos this code works happily for me on my Visual Basic V6 system.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width