Reputation: 17
I am making a directory cleaner that uses the following code
Label2.Text = "Cleaned."
If CheckBox1.Checked = True Then
On Error Resume Next
Kill("C:\Nexon\Combat Arms\*.txt")
End If
If CheckBox2.Checked = True Then
On Error Resume Next
Kill("C:\Nexon\Combat Arms\*.jpg")
End If
If CheckBox3.Checked = True Then
On Error Resume Next
Kill("C:\Nexon\Combat Arms\*.v3d")
End If
If CheckBox4.Checked = True Then
On Error Resume Next
Kill("C:\Nexon\Combat Arms\*.bin")
End If
If CheckBox5.Checked = True Then
On Error Resume Next
Kill("C:\Nexon\Combat Arms\*.dmp")
End If
If CheckBox6.Checked = True Then
On Error Resume Next
Kill("C:\Nexon\Combat Arms\*.dump")
End If
If CheckBox7.Checked = True Then
On Error Resume Next
System.IO.File.SetAttributes("C:\Nexon\Combat Arms\EndingBanner.exe", System.IO.FileAttributes.Normal)
Kill("C:\Nexon\Combat Arms\EndingBanner.exe")
End If
If CheckBox8.Checked = True Then
On Error Resume Next
System.IO.File.SetAttributes("C:\Nexon\Combat Arms\CAV.exe", System.IO.FileAttributes.Normal)
Kill("C:\Nexon\Combat Arms\CAV.exe")
End If
If CheckBox9.Checked = True Then
On Error Resume Next
If Dir("C:\Nexon\Combat Arms\MOVIES") <> "" Then
Rename("C:\Nexon\Combat Arms\Game\MOVIES", "C:\Nexon\Combat Arms\Game\CLEANED")
End If
End If
But instead of stating the directory in the program I want the user to select it , "C:\Nexon\Combat Arms\" using SelectDirectory; I have this but, cant make it work
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog
Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()
Me.FileReference.Text = MyFolderBrowser.SelectedPath
End Sub
Upvotes: 0
Views: 645
Reputation: 21
Try using a message box to display the selected path. See if is giving you what you want. If this isn't working try another property like selected directory or sorts. I don't have VS open right now to look myself but what you have should work as long as selected path is right. I have a feeling that if you got the selected path if that is what you want and assign it to a string variable first, it might work. Could be a formatting problem with the path. Just try the message box first to see if the path is right.
Upvotes: 0
Reputation: 12804
The folderbrowser code works fine. Are you having a problem implementing this?
Kill(Me.FileReference.Text & "\*.txt")
Upvotes: 1