Results 1 to 7 of 7

Thread: [RESOLVED] How to add a progressbar to a FileSystemObject process

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    Resolved [RESOLVED] How to add a progressbar to a FileSystemObject process

    I am, for the first time ever, using the FileSystemObject to handle the copying and moving of large folders (Outlook Express message folders in this case).

    The aim is to write a program which "seamlessly" replaces an existing message store by a previous (older) one, and then when desired restores the existing folder.

    So far my code is working, but because these can be large folders (1.5 gb) the process takes a while and I would like to be able to display a progressbar.

    How please can a progressbar be added to a statement such as :

    FSO.Copyfolder "C:\SourceFolderName", "C:\Tempfoldername"

    to indicate the degree of progress, and to show the user that the copy action is in progress - not crashed?

    camoore

    Wales, UK

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How to add a progressbar to a FileSystemObject process

    The FSO was designed for non-GUI scripting environments. As a result it provides no progress callbacks or events for lengthy operations, and operates strictly synchronously making it a very poor choice for use in a VB6 program. Most likely Windows will end up marking you unresponsive during a lengthy call.

    If you need this level of functionality you will just have to write more code.

    "Progress" is a little hard to define for such an operation anyway. What would 50% mean? or 90%?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    Re: How to add a progressbar to a FileSystemObject process

    Hi dilettante, and thanks for a very swift reply.

    If therefore the FSO is not the best method to be trying to apply, can you please suggest what might be a better approach?

    As to the definition of "progress" here, I would seek to measure the size of the source folder and then to display as a progressbar the %age size of the new folder into which it is being copied.

    camoore

    Wales, UK

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How to add a progressbar to a FileSystemObject process

    To determine the "size" requires recursively iterating over all of the files and subfolders and adding the sizes up, an expensive operation almost as complex as performing the copy itself.

    As for what tools to use you could use the existing things in VB6 like Dir$(), FileCopy, etc. Of course FileCopy is still synchronous so for large files it will still "hang."

    The alternative would involve API calls or perhaps some 3rd party component.


    Even Explorer normally just plays a "copy" animation, and doesn't attempt to disaply progress.

  5. #5
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: How to add a progressbar to a FileSystemObject process

    I'm sorry but I'm just too tempted to post this


  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How to add a progressbar to a FileSystemObject process

    Hah! I'd forgotten they do that.

    See CopyFileEx Function

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    Re: How to add a progressbar to a FileSystemObject process

    Thanks for further interesting replies. I like that cartoon baja yu! How well that sums up the progress messages Windows often displays during file copy/transfer.

    I have worked out a way to solve my problem by a sequence of re-naming folders rather than making copies of them, which will be much faster and obviate a need for a progress bar.

    Hence will mark this thread resolved. Regards,


    camoore

    Wales, UK

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