Displaying progress bar during copying files

I'd like to implement progress bar displaying the progress of copying files.
look at following
---------------
Set fs=CreateObject("Scripting.FileSystemObject")
fs.CopyFile "C:\TEST\"+"*.*", "A:\TEST\"
---------------
During execute this, I cannot know the file name and the size of the file that is copied.
And I must know these information to display progress bar.
Could anyone who know the way let me know?
Thak you.

I'm a senior programmer.
Working at CamSight, Dental imaging solutions industry.
[559 byte] By [Jeong] at [2007-11-15 16:16:43]
# 1 Re: Displaying progress bar during copying files
You will not be able to show a progressbar if you copy file that way. If you want to keep track, you have to:
1)make a list of all the files you want to copy,
2)copy file one by one, and meanwhile pass a value to your proogressbar to update or rise an event in your client (if his is a component) to redraw teh progressbar

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood,
Bruno Paris and all the other wonderful people who made and make dev-archive
a great place.
Come back soon, you Gurus.
Cimperiali at 2007-11-10 0:59:09 >
# 2 Re: Displaying progress bar during copying files
There are two API functions that allow you to copy files with a progress bar type effect as happens when you copy using explorer: CopyFileEx and MoveFileWithProgress.

Both allow you to pass a proc address which will be triggered whenever the copy function completes copying a chunk of the file(s).

Do a search for these commands here or at http://msdn.microsoft.com for more info.

HTH,
Duncan

---------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
Clearcode at 2007-11-10 1:00:09 >
# 3 Re: Displaying progress bar during copying files
Because you don't know the file size during the coprying you have to show a user an animation that something is going on. Here is the code similar to MS Copy:

'this proc will copy files and shows an animated picture (it will create a folder if it does not exist)

Private Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
Private Const FO_DELETE = &H3
Private Const FO_COPY = &H2
Private Const FO_MOVE = &H1
Private Const FO_RENAME = &H4
Private Const FOF_ALLOWUNDO = &H40
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Private Sub Command1_Click()
Dim SHFileOp As SHFILEOPSTRUCT

With SHFileOp
.pFrom = "c:\IouriApps\*.*"
.pTo = "c:\temp\download"
.wFunc = FO_COPY
End With
'perform file operation
SHFileOperation SHFileOp
MsgBox "The Folder '" + SHFileOp.pFrom + "' has been Copied To : " & SHFileOp.pTo, vbInformation + vbOKOnly, App.Title
End Sub

Iouri Boutchkine
iouri@hotsheet.com
Iouri at 2007-11-10 1:01:14 >