|
-
Jun 4th, 2010, 05:43 PM
#1
Thread Starter
Hyperactive Member
[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
-
Jun 4th, 2010, 05:49 PM
#2
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%?
-
Jun 4th, 2010, 05:58 PM
#3
Thread Starter
Hyperactive Member
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
-
Jun 4th, 2010, 08:03 PM
#4
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.
-
Jun 4th, 2010, 08:11 PM
#5
Re: How to add a progressbar to a FileSystemObject process
I'm sorry but I'm just too tempted to post this 
-
Jun 4th, 2010, 08:11 PM
#6
Re: How to add a progressbar to a FileSystemObject process
Hah! I'd forgotten they do that.
See CopyFileEx Function
-
Jun 5th, 2010, 06:01 AM
#7
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|