Hello,
I am trying to create an application that cleans the current directory
i.e Cleanup/text folder >> test.txt and 2test.txt ect...
I have two problems:
1st I cannot cleanup all of the Shortcut files i.e. Adobe.lnk ect...
###########################################################################
Here is what I have so far for the .lnk files:
Dim myPatheight As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Shortcuts")
IO.Directory.CreateDirectory(myPatheight)
For Each foundFile1 As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.lnk")
count = ++count
Try
My.Computer.FileSystem.MoveFile(foundFile1, myPatheight & "/" & IO.Path.GetFileName(foundFile1))
Catch
If My.Computer.FileSystem.FileExists(foundFile1) Then
MsgBox("File: " & foundFile1 & " already belongs to the: " & myPatheight & " directory. Please, choose a directory to move it to")
SaveFileDialog1.InitialDirectory = myPath
SaveFileDialog1.FileName = foundFile1.Replace(".lnk", ++count & ".lnk")
SaveFileDialog1.Filter = "Shortcuts (*.lnk)|*.lnk|All Files (*.*)|*.*"
SaveFileDialog1.ShowDialog()
My.Computer.FileSystem.DeleteFile(foundFile1)
End If
End Try
Next
#################
Any hints?
##################
Next: I am having a problem with keeping "THIS APP" from moving to the Cleanup folder..
And even when I use the TRY/CATCH and do not move it using the SaveFile Dialog: I get the error message that is attached...
##############################################
Here is what I have:
Dim myPathsix As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Programs")
IO.Directory.CreateDirectory(myPathsix)
Dim count As Integer = 1
For Each foundFile7 As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.exe") '& "*.png" & "*.gif")
count = ++count
Try
Dim foundNOT As String = foundFile7.Contains("Folder Cleanup Application.exe")
My.Computer.FileSystem.MoveFile(foundFile7, myPathsix & "/" & IO.Path.GetFileName(foundFile7))
If foundFile7.Contains(foundNOT) Then
My.Computer.FileSystem.MoveFile(foundNOT, myPathsix & "/" & IO.Path.GetFileName(foundNOT), False)
End If
Catch
If My.Computer.FileSystem.FileExists(foundFile7) Then
MsgBox("File: " & foundFile7 & " already belongs to the: " & myPathsix & " directory. Please, choose a directory to move it to")
SaveFileDialog1.InitialDirectory = myPath
SaveFileDialog1.ShowDialog()
My.Computer.FileSystem.DeleteFile(foundFile7)
End If
End Try
Next
######################
Any hints?
#######################
Thanks in advance,
M1234ike