Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB File Copy

Status
Not open for further replies.

bitshifter05

Programmer
Jul 15, 1999
13
US
I need to know when a file copy has been complete. In my program I am copying many files to a zip drive and I wanted to display a status bar to display the status of the file copy and notify when complete. thanks kevin<br>
<br>

 
Take Window animation when copy the same file to a zip drive :<br>
<br>
Option Explicit<br>
<br>
Private Type SHFILEOPSTRUCT<br>
hWnd As Long<br>
wFunc As Long<br>
pFrom As String<br>
pTo As String<br>
fFlags As Integer<br>
fAnyOperationsAborted As Boolean<br>
hNameMappings As Long<br>
lpszProgressTitle As String<br>
End Type<br>
<br>
Private Declare Function SHFileOperation Lib &quot;shell32.dll&quot; Alias &quot;SHFileOperationA&quot; (lpFileOp As SHFILEOPSTRUCT) As Long<br>
<br>
Private Const FO_COPY = &H2<br>
Private Const FOF_ALLOWUNDO = &H40<br>
<br>
Public Sub SHCopyFile(ByVal from_file As String, ByVal to_file As String)<br>
Dim sh_op As SHFILEOPSTRUCT<br>
<br>
With sh_op<br>
.hWnd = 0<br>
.wFunc = FO_COPY<br>
.pFrom = from_file & vbNullChar & vbNullChar<br>
.pTo = to_file & vbNullChar & vbNullChar<br>
.fFlags = FOF_ALLOWUNDO<br>
End With<br>
<br>
SHFileOperation sh_op<br>
End Sub<br>
<br>
Your codes with :<br>
<br>
SHCopyFile Bestand, CommonDialog1.Filename<br>
<br>
Eric<br>
<br>
<br>
<p>Eric De Decker<br><a href=mailto:vbg.be@vbgroup.nl>vbg.be@vbgroup.nl</a><br><a href= Basic Center</a><br>
 
I have a UserControl fixed the question of kevin :<br>
<br>
' Update the status progress bar and label.<br>
Private Sub FileCopier1_Progress(ByVal total_bytes As Long, ByVal bytes_copied As Long)<br>
' See if we know how many bytes we will copy.<br>
If total_bytes = 0 Then<br>
' We don't know how many bytes we will copy.<br>
' Display the caption.<br>
lblStatus.Caption = Format$(bytes_copied) & _<br>
&quot; bytes copied&quot;<br>
<br>
' Hide the progress bar.<br>
prgStatus.Visible = False<br>
Else<br>
' We do know how many bytes we will copy.<br>
' Display the caption.<br>
lblStatus.Caption = Format$(bytes_copied) & _<br>
&quot; of &quot; & Format$(total_bytes) & &quot; bytes copied&quot;<br>
<br>
' If this is the first status update,<br>
' set the progress bar's Min and Max<br>
' properties.<br>
If Not prgStatus.Visible Then<br>
prgStatus.Min = 0<br>
prgStatus.Max = total_bytes<br>
End If<br>
<br>
' Update the progress bar.<br>
prgStatus.Value = bytes_copied<br>
If Not prgStatus.Visible Then prgStatus.Visible = True<br>
End If<br>
<br>
' Make sure the status label is visible.<br>
If Not lblStatus.Visible Then lblStatus.Visible = True<br>
End Sub<br>
<p>Eric De Decker<br><a href=mailto:vbg.be@vbgroup.nl>vbg.be@vbgroup.nl</a><br><a href= Basic Center</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top