Causing a batch file to finish its operations, before continuing?

The following code will extract files modified today from the SourceDirectory and place them into the FilesExtracted folder, then the batch file will delete the rest of the files in the sourceDirectory. But after that is all done a brand new set of files will be copied from the OriginalTestFiles folder and put into the sourceDirectory, but its does not do it. Does anyone think that it could be because the batch files hasn't stopped its operations and is still deleting the files in the sourceDirectory, or is there another problem. Thank You all!

Imports System.IO

Public Class frmExtractionator

'  Dim txtFiles1 As Control
Dim sourceDirectory As String = "F:\CopierFolderforTestDriveCapstone"
Dim archiveDirectory As String = "F:\FilesExtracted"
Dim originalDirectory As String = "F:\OriginalTestFiles"

Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click


        Dim txtFiles = Directory.EnumerateFiles(sourceDirectory)

        If (Not System.IO.Directory.Exists(archiveDirectory)) Then
        End If

        For Each currentFileLoc As String In txtFiles

            Dim fileName = currentFileLoc.Substring(sourceDirectory.Length + 1)

            If (IO.File.GetLastWriteTime(currentFileLoc).ToString("MM/dd/yyyy") = DateTime.Now.ToString("MM/dd/yyyy")) Then
                MessageBox.Show(currentFileLoc & " moved", "Moved Succesfully")
                File.Move(currentFileLoc, Path.Combine(archiveDirectory, fileName))

            End If

    Catch eT As Exception
    End Try


        Dim txtFiles2 = Directory.EnumerateFiles(originalDirectory)

        For Each currentFileLoc2 As String In txtFiles2

            Dim fileName = currentFileLoc2.Substring(originalDirectory.Length + 1)

            File.Move(currentFileLoc2, Path.Combine(sourceDirectory, fileName))

    Catch eT As Exception
    End Try
End Sub

End Class


You can get the process as a variable once you start it and wait for it to exit:

Dim theProcess As Process = Process.Start("F:\poop.bat")

Try monitoring the Process for completion...

'Start the process.
Dim Proc = Process.Start("F:\poop.bat")
'Wait for the window to finish loading.
'Wait for the process to end.


Need Your Help

Mysqli and PDO combined with Javascript and Ajax… possible?

php ajax mysqli

Simple question from a noob programer. Thinking of several different styles and features to a project i have for a social website. question is this...

Get last MySQL binary log entry


I'm using MySQL replication, and I'd like a status script running on the slave to report the last statement that was replicated over to the slave.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.