CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Type Mismatch

  1. #1
    Join Date
    Sep 2001
    Posts
    5

    Type Mismatch

    I am trying to automate cuteftp pro with scripts written in vbscript. My problem is, I need to upload all the files from a local directory into another directory on a remote site. I have used *.*, *.jpg and nothing works. It keeps telling me that file or directory not found. I t doesnt seem to understand *.* or *.jpg If someone can help it would be very appreciated. Someone suggested using Dir but i get an error when using that like Type Mismatch Dir
    Some code:

    strPath = "J:\Carsdata\385005"
    strFile = Dir(strPath & "\*.jpg")

    Do until strFile = ""
    MySite.Upload strPath & "\" & strFile
    strFile = Dir
    Loop

    If I Use MySite.Upload "J:\Carsdata\385002\ It uploads the whole folder and the files. I need to upload just the files into another directory.

    Thanks!



  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Type Mismatch

    Ok, I think I found it. The Dir function cannot be used from VBScript. You must use the FileSystemObject instead.

    ' This code shows the name of all the jpg files in c:\
    Dim fs, drv, fldr, fle
    set fs = CreateObject("Scripting.FileSystemObject")
    set Fldr = fs.GetFolder("C:\")
    for each fle in Fldr.Files
    if mid(fle.name,len(fle.name) -3) = ".jpg" then msgbox fle.name
    next




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

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

Featured