Results 1 to 4 of 4

Thread: Problems with FileSystemObject

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    2

    Problems with FileSystemObject

    I have built a VB app to take in a query of product #s, then search for all pictures associated with that product on a local machine, then those that are found are copied into a seperate file to be distributed out. The probloem I am having is that it is very slow, and yet it only uses 10% CPU Max and 17,000 k memory max. I need to find a way to speed it up, if anyone has any suggestions.

    Thanks,
    Dan

    Code snippet here (which is called passing in the ProdNums in a loop over the recordset):
    VB Code:
    1. Private Sub CopyPhotos(ProdNum)
    2.     Dim intCntr, LastTwo As Integer
    3.     Dim ThisPhoto, ThisPhotoPath As String
    4.     LastTwo = Right(ProdNum, 2)
    5.     ThisPhotoPath = RootPath & "\" & LastTwo
    6.     intCntr = 0
    7.     'On Error GoTo errHandler
    8.     'Check that the photo folder exists
    9.     If Not myFSO.FolderExists(ThisPhotoPath) Then
    10.         GoTo NoFolder
    11.     End If
    12.     'Check Desitnation Folder
    13.     If Not myFSO.FolderExists(CopyPath & "\" & LastTwo) Then
    14.         myFSO.CreateFolder CopyPath & "\" & LastTwo
    15.     End If
    16.     'Loop over all possible photo combos
    17.     Do While intCntr <= MaxPhotos
    18.         'Check for this photo
    19.         ThisPhoto = ThisPhotoPath & "\" & ProdNum& "_" & intCntr & ".jpg"
    20.         If Not myFSO.FileExists(ThisPhoto) Then
    21.             GoTo NoPhoto
    22.         End If
    23.         myFSO.CopyFile ThisPhoto, CopyPath & "\" & LastTwo & "\"
    24. NextPhoto:
    25.         intCntr = intCntr + 1
    26.     Loop
    27.     GoTo UnloadSub
    28. NoFolder:
    29.     WriteUserError ("Folder for " & ProdNum& " Photo does not exist ( " & ThisPhotoPath & " )")
    30.     GoTo UnloadSub
    31. NoPhoto:
    32.     WriteUserError ("Photo for " & ProdNum& " Photo does not exist ( " & ThisPhoto & " )")
    33.     GoTo NextPhoto
    34. UnloadSub:
    35.     Exit Sub
    36. errHandler:
    37.     If ErrMustStop Then Debug.Assert False: Resume
    38.     ErrorIn "Form1.MoveFiles(RootPath)", RootPath
    39. End Sub



    Edit: Added [vbcode][/vbcode] tags for clairty. - Hack
    Last edited by Hack; Jun 23rd, 2005 at 08:41 AM.

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