Hello,
I need some help making a "Windows-Like" copy and replace prompt with this folder cleanup application below.
The application uses a Windows Form and two buttons: one to create the separate subfolders in the main Cleanup folder and another for special folders.
Take a look:
***************************************************************
Imports IWshRuntimeLibrary
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myPathseven As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup")
IO.Directory.CreateDirectory(myPathseven)
Dim myPatheight As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Shortcuts")
IO.Directory.CreateDirectory(myPatheight)
Dim myPath As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Text")
IO.Directory.CreateDirectory(myPath)
Dim myPathtwo As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Documents")
IO.Directory.CreateDirectory(myPathtwo)
Dim myPaththree As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Videos")
IO.Directory.CreateDirectory(myPaththree)
Dim myPathfour As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Music")
IO.Directory.CreateDirectory(myPathfour)
Dim myPathfive As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Pictures")
IO.Directory.CreateDirectory(myPathfive)
Dim myPathsix As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/Programs")
IO.Directory.CreateDirectory(myPathsix)
Dim count As Integer = 1
On Error Resume Next
If Not IO.Directory.Exists(myPath) Then IO.Directory.CreateDirectory(myPath)
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.txt")
My.Computer.FileSystem.MoveFile(foundFile, myPath & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.lnk")
My.Computer.FileSystem.MoveFile(foundFile, myPatheight & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.URL")
My.Computer.FileSystem.MoveFile(foundFile, myPatheight & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.jpg") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathfive & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.png") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathfive & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.gif") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathfive & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile0 As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.bmp") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile0, myPathfive & "/" & IO.Path.GetFileName(foundFile0))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.rtf") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathtwo & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.docx") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathtwo & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.pdf") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathtwo & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.pptx") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathtwo & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.ppt") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathtwo & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.xls") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathtwo & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.doc") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathtwo & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.xlsx") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathtwo & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.avi") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPaththree & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.mpg") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPaththree & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.mov") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPaththree & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.wmv") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPaththree & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.mpeg") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPaththree & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.swf") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPaththree & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.mp4") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPaththree & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.mp3") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathfour & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.wma") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathfour & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.wav") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathfour & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.ogg") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathfour & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.html") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.css") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.pl") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.exe") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "Folder Cleanup Application.exe")
My.Computer.FileSystem.CopyFile(foundFile, CurDir)
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
My.Computer.FileSystem.DeleteFile(foundFile)
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.rar") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.zip") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.pl") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.msi") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.tar") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.vm") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.gz") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.php") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory, _
FileIO.SearchOption.SearchTopLevelOnly, "*.cgi") '& "*.png" & "*.gif")
My.Computer.FileSystem.MoveFile(foundFile, myPathsix & "/" & IO.Path.GetFileName(foundFile))
Next
On Error Resume Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim myPathCreate As String = IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Cleanup/" & TextBox1.Text)
IO.Directory.CreateDirectory(myPathCreate)
End Sub
End Class
*********************
Somewhere in this program I need to prompt the user if the user wants to overwrite the existing files in the Cleanup/ folders.
Any help?
Thanks in advance,
M1234ike