By Ken Huysmans on
2005-08-03T10:49:02
Today I wanted to create a control that could copy files in VB.NET with some progress indication. I did some searches on the Internet and managed to build a working control. However, I would like to share the basics with all of you...
First declare some API functions:
Private Delegate Function CopyProgressRoutine(ByVal totalFileSize As Int64, ByVal totalBytesTransferred As Int64, ByVal streamSize As Int64, ByVal streamBytesTransferred As Int64, ByVal dwStreamNumber As Int32, ByVal dwCallbackReason As Int32, ByVal hSourceFile As Int32, ByVal hDestinationFile As Int32, ByVal lpData As Int32) As Int32
Private Declare Auto Function CopyFileEx Lib "kernel32.dll" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As CopyProgressRoutine, ByVal lpData As Int32, ByVal lpBool As Int32, ByVal dwCopyFlags As Int32) As Int32
Add a button (Button1) to your form and add this code to the Click event:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)...
Read More »