I am making application that sends all the programs (.exe) into a created folder on the current directory.
The application is setup by first creating a folder at the push of a button.
Next, a try catch is used to send all of the .exe files into the new folder.
Below is some of the source code, I want to know how make an exception for this running application .
Any hints?
Dim myPathsix As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Programs")
IO.Directory.CreateDirectory(myPathsix)
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")
count = ++count
Try
My.Computer.FileSystem.MoveFile(foundFile2, myPathsix & "/" & IO.Path.GetFileName(foundFile2))
Catch
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| (All Files (*.*)|*.*"
SaveFileDialog1.ShowDialog()
My.Computer.FileSystem.DeleteFile(foundFile2)
End If
End Try
'**************************************************************************************
'I want to add another Try/Catch or a nested Try/Catch to catch the currently running program " WHATEVER.exe" 'or this application' as an exception, so it does not move from its currently stationed directory
'**************************************************************************************
Next