[Help]How to wait for a function to finish?
I'm currently using a CopyFiles function to copy files from different places but the problem is, when I use the function, they all 'pile' on top of each other and I want it so it waits for 1 to finish then do the next and etc...
[php]
Public Sub CopyFiles(ByVal sourcePath As String, ByVal DestinationPath As String)
Dim start As Integer
Dim prog As Decimal
If (Directory.Exists(sourcePath)) Then
ProgressBar1.Value = 0
start = 0
prog = System.IO.Directory.GetFiles(sourcePath).Length
For Each fName As String In Directory.GetFiles(sourcePath)
If File.Exists(fName) Then
Dim dFile As String = String.Empty
dFile = Path.GetFileName(fName)
Dim dFilePath As String = String.Empty
dFilePath = DestinationPath + dFile
File.Copy(fName, dFilePath, True)
start += 1
ProgressBar1.Value = (start * 100) / prog
End If
Next
End If[/php]
If there is a better way to copy files, please elaborate.
[php]
Public Sub CopyFiles(ByVal sourcePath As String, ByVal DestinationPath As String)
Dim start As Integer
Dim prog As Decimal
If (Directory.Exists(sourcePath)) Then
ProgressBar1.Value = 0
start = 0
prog = System.IO.Directory.GetFiles(sourcePath).Length
For Each fName As String In Directory.GetFiles(sourcePath)
If File.Exists(fName) Then
Dim dFile As String = String.Empty
dFile = Path.GetFileName(fName)
Dim dFilePath As String = String.Empty
dFilePath = DestinationPath + dFile
File.Copy(fName, dFilePath, True)
start += 1
ProgressBar1.Value = (start * 100) / prog
End If
Next
End If[/php]
If there is a better way to copy files, please elaborate.


