MaxDes 0 Newbie Poster

Anyone have a clue. This is pretty straight foward and it's mostly copied from another program I use right now and that program works perfectly... I just don't know what the heck is up. Any help would be appreciated!!!!

I have made test files to work with as well as emulated the network drives and naming convention that the software is looking for. It starts the BGW as I cn see by adding a label text change at the end of the start button commands, but it doesn't seem to pick up the files... I have tried copy and cut both as well as actually going through the network to drop the files, nothing happens. it's like no files were dropped into the "hot folder"

Option Strict Off
Imports System.IO
Imports System.Collections.Generic
Public Class Form1
    Inherits System.Windows.Forms.Form
    Public Function ExecCommand(ByRef CommandLine As String, _
                        Optional ByRef Arguments As String = "", _
                        Optional ByRef Waitforexit As Boolean = True) As Integer
        Dim psi As New ProcessStartInfo()
        Dim p As Process

        With psi
            .FileName = CommandLine
            .Arguments = Arguments
            .WindowStyle = ProcessWindowStyle.Hidden 'This avoid a text window being opened
        End With
        Try
            p = Process.Start(psi) 'This line runs the command
            If Waitforexit Then p.WaitForExit() 'This wait until the command ends

            While Not p.HasExited
                System.Windows.Forms.Application.DoEvents()
            End While

            Return p.ExitCode
        Catch e As System.Exception
            'Catch errors here
        End Try
    End Function
    Private Sub bgw_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgw.DoWork
        Dim FileName As String
        Dim HasMoreItems As Boolean

        While True
            Files.MRE.Reset()
            HasMoreItems = False
            Do
                FileName = Nothing
                SyncLock Files.SharedObject
                    If Files.ToBeProcessed.Count > 0 Then
                        FileName = Files.ToBeProcessed.Peek
                    End If
                End SyncLock
                If Not IsNothing(FileName) Then
                    While IsFileInUse(FileName)
                        Debug.Print(DateTime.Now.ToString() & " : File in use!  Waiting 5 seconds...")
                        System.Threading.Thread.Sleep(5000) ' wait 5 seconds to try again
                    End While


                    Try

                        If FileName.Contains("15Mbps") Then System.IO.File.Copy("C:\video\" & FileName, "X:\encoded2\mcvod\transcode_needed" & FileName, True) Else 
                        System.IO.File.Copy("C:\video\" & FileName, "Z:\" & FileName, True)
                        System.IO.File.Copy("C:\video\" & FileName, "X:\Encoded2\" & FileName, True)
                        If FileName.Contains("HD") Then HDList.Items.Add(FileName)
                        If FileName.Contains("FVOD") Then FVODList.Items.Add(FileName)
                        If FileName.Contains("15Mbps") Then IPVODList.Items.Add(FileName)
                        If FileName.Contains("HD") Or ("FVOD") Or ("15Mbps") Then BadLabel.ForeColor = Color.Green Else BadList.Items.Add(FileName)

                        System.IO.File.Delete("c:\video\" & FileName)
                        SyncLock Files.SharedObject
                            Files.ToBeProcessed.Dequeue()
                        End SyncLock
                        bgw.ReportProgress(0, FileName)
                    Catch ex As Exception
                        System.Threading.Thread.Sleep(5000) ' wait 5 seconds before trying again

                    End Try
                End If

                SyncLock Files.SharedObject
                    HasMoreItems = (Files.ToBeProcessed.Count > 0)
                End SyncLock
            Loop While HasMoreItems
            Files.MRE.WaitOne()
        End While
        'End If
    End Sub
    Private Sub bgw_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bgw.ProgressChanged
        'If e.UserState.ToString.Contains("HD") Then HDList.Items.Add(Now.ToString() & " Processed " & e.UserState.ToString())
        'If e.UserState.ToString.Contains("FVOD") Then FVODList.Items.Add(Now.ToString() & " Processed " & e.UserState.ToString())
        'If e.UserState.ToString.Contains("15Mbps") Then IPVODList.Items.Add(Now.ToString() & " Processed " & e.UserState.ToString())
        'If e.UserState.ToString.Contains("HD") Or ("FVOD") Or ("15Mbps") Then BadLabel.ForeColor = Color.Green Else BadList.Items.Add(Now.ToString() & " Processed " & e.UserState.ToString())
        HDList.Items.Add(Now.ToString() & " Processed " & e.UserState.ToString())

    End Sub
    Public Class Files
        Public Shared ToBeProcessed As New Queue(Of String)
        Public Shared SharedObject As New Object
        Public Shared MRE As New System.Threading.ManualResetEvent(False)
    End Class
    Private m_WatchDirectory As String
    Private WithEvents m_FileSystemWatcher As FileSystemWatcher
    Private WithEvents bgw As New System.ComponentModel.BackgroundWorker


    Private Delegate Sub mProcessFileDelegate(ByVal file_name As String)
    ' Process a new file.
    Private Sub m_FileSystemWatcher_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles m_FileSystemWatcher.Created

        SyncLock Files.SharedObject
            If Not Files.ToBeProcessed.Contains(e.Name) Then
                Files.ToBeProcessed.Enqueue(e.Name)
                Files.MRE.Set()
            End If
        End SyncLock
    End Sub
    Private Function IsFileInUse(ByVal fileName As String) As Boolean

        Dim watchlocation As String
        watchlocation = "C:\Video\"

        Try
            Using fs As New FileStream(watchlocation & fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.None)
            End Using
            Return False
        Catch ex As Exception
            Debug.Print("IsFileInUse(): " & ex.ToString)
            Return True
        End Try
    End Function


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        testlabel.Text = "StartLabel Button Pushed"
        StartLabel.Text = "Started"
        bgw.WorkerSupportsCancellation = True
        bgw.WorkerReportsProgress = True
        bgw.RunWorkerAsync()

        m_WatchDirectory = (m_WatchDirectory & "C:\Video\")

        ' Make the FileSystemWatcher.
        m_FileSystemWatcher = New FileSystemWatcher("C:\Video\", "*.mpg")
        m_FileSystemWatcher.NotifyFilter = 0
        m_FileSystemWatcher.NotifyFilter = m_FileSystemWatcher.NotifyFilter Or NotifyFilters.FileName
        m_FileSystemWatcher.EnableRaisingEvents = True

        testlabel.Text = "start Button Finished"
    End Sub
End Class