Dim myPathsix As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Programs")
        Dim count As Integer = 1

If Not IO.Directory.Exists(myPathsix) Then IO.Directory.CreateDirectory(myPathsix) '// create if it does not exist. 
For Each foundFile2 As String In My.Computer.FileSystem.GetFiles _
         (My.Computer.FileSystem.CurrentDirectory, _
         FileIO.SearchOption.SearchTopLevelOnly, "*.exe" & "*.pl" & "*.jar" & "*.zip" & "*.rar")
            count = ++count

                My.Computer.FileSystem.MoveFile(foundFile2, myPathsix & "/" & IO.Path.GetFileName(foundFile2))

                If My.Computer.FileSystem.FileExists(foundFile2) Then
                    MsgBox("File: " & foundFile2 & " already belongs to the: " & myPathsix & " directory. Please, choose a directory to move it to")
                    SaveFileDialog1.InitialDirectory = myPath
                    SaveFileDialog1.FileName = foundFile2.Replace(".exe", ++count & ".exe")
                    SaveFileDialog1.Filter = "Programs (*.exe)|*.exe| (*.jar)|*.jar|(*.pl)|*.pl|(*.rar)|*.rar|(*.zip)|*.zip| (All Files (*.*)|*.*"

                End If
            End Try
'I want to add another Try/Catch to catch the currently running program " WHATEVER.exe" 'or [B]this application[/B]
'as an exception, so it does not move from its currently stationed directory
Dim Proc() As Process = Process.GetProcessesByName('Program name (as string))
        If Proc.Rank <> 0 Then
            MsgBox("Program is Running!")
        End If
This article has been dead for over six months. Start a new discussion instead.