我希望它执行以下操作:当他们单击导入按钮时,打开多个文件(完成),然后将其保存为设置。然后在表单加载时,打开这些文件,这样我就不必重新导入它们了!
我试过这个
For Each wl As String In File.ReadAllLines("settings.txt")
OpenFileDialog1.FileName = (wl)
Next
表单加载和settings.txt上的包括2个文件名和位置。它只打开第二个文件而不是第一个。如何在该设置文件中打开所有文件?我还绑了ReadLines
答案 0 :(得分:0)
将hash-cracker方法抽象出来可能最简单:
Function hashType(ByVal filename As String) As Boolean
If algo.Text = "MD5" Then
Dim firstWord = (From word In IO.File.ReadLines(filename)
Where String.Equals(MD5(word), hash.Text)).FirstOrDefault()
If firstWord IsNot Nothing Then
Label2.Text = firstWord
Return True
Else
Label2.Text = "Hash Could Not Be Cracked"
End If
ElseIf algo.Text = "SHA1" Then
Dim firstWord = (From word In IO.File.ReadLines(filename)
Where String.Equals(SHA1(word), hash.Text)).FirstOrDefault()
If firstWord IsNot Nothing Then
Label2.Text = firstWord
Return True
Else
Label2.Text = "Hash Could Not Be Cracked"
End If
End If
Return False
End Function
Private Sub Thief3Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Thief3Button1.Click
OpenFileDialog1.Filter = "Dictionaries (*.dic)|*.dic"
OpenFileDialog1.FilterIndex = 1
OpenFileDialog1.RestoreDirectory = True
OpenFileDialog1.Multiselect = True
OpenFileDialog1.ShowDialog()
End Sub
Private Sub Thief3TopButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Thief3TopButton1.Click
Me.Close()
End Sub
Private Sub Thief3Button3_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Thief3Button2.Click
hashType(OpenFileDialog1.FileName)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each wl As String In File.ReadLines("settings.txt")
If hashType(wl) Then Exit For
Next
End Sub
瞧。我想你可能想要在Load
事件之外的其他地方这样做 - 但是在首次创建表单时hash.Text
中没有任何内容。