0

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
4

2 に答える 2

1

folderbrowser コードは正常に動作します。これを実装するのに問題がありますか?

Kill(Me.FileReference.Text & "\*.txt")
于 2011-12-14T00:54:45.383 に答える
0

メッセージ ボックスを使用して、選択したパスを表示してみてください。があなたが望むものを与えているかどうかを確認してください。これが機能しない場合は、選択したディレクトリや並べ替えなどの別のプロパティを試してください。現在、自分自身を見るためにVSを開いていませんが、選択したパスが正しい限り、あなたが持っているものは機能するはずです。選択したパスが必要な場合に取得し、それを最初に文字列変数に割り当てると、うまくいくかもしれないと感じています。パスのフォーマットに問題がある可能性があります。最初にメッセージ ボックスを試して、パスが正しいかどうかを確認してください。

于 2012-03-23T02:07:05.557 に答える