2011-12-14 153 views
0

我正在使用下面的代碼但的Visual Basic,代碼清潔

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 

,而不是說明在我希望用戶選擇它的程序的目錄的目錄清潔劑,「C:\ Nexon公司\戰鬥Arms \「使用SelectDirectory;我有這個但是,不能讓它工作

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 
+2

「不能使它工作」不會告訴我們任何事情。你嘗試了什麼,以及你觀察到了什麼意外的行爲? – 2011-12-14 00:31:59

回答

1

該folderbrowser代碼工作正常。你在執行這個問題時遇到問題嗎?

Kill(Me.FileReference.Text & "\*.txt") 
0

嘗試使用消息框來顯示選定的路徑。看看是否給你你想要的東西。如果這不起作用,請嘗試另一個屬性,如選定的目錄或排序。我現在沒有打開VS來看自己,但只要選擇的路徑正確,你應該有什麼工作。我有一種感覺,如果你得到了選擇的路徑,如果這是你想要的,並首先將它分配給一個字符串變量,它可能會工作。可能是路徑的格式問題。只需先嚐試消息框,看看路徑是否正確。