问题描述
我在这个示例项目中有几行代码。
I have a few lines of code here from a sample project.
Function md5_hash(ByVal file_name As String)
Return hash_generator("md5", file_name)
End Function
Function hash_generator(ByVal hash_type As String, ByVal file_name As String)
Dim hash
hash = MD5.Create
Dim hashValue() As Byte
Dim filestream As FileStream = File.OpenRead(file_name)
filestream.Position = 0
hashValue = hash.ComputeHash(filestream)
Dim hash_hex = PrintByteArray(hashValue)
filestream.Close()
Return hash_hex
End Function
Private Sub BunifuThinButton21_Click(sender As Object, e As EventArgs) Handles BunifuThinButton21.Click
Dim path As String = OpenFileDialog1.FileName
Dim sample As String
sample = md5_hash(path)
End Sub
当你加入在此代码中看到,OpenFileDialog用于声明正在检查的文件的路径,以查看它是否具有与MD5哈希数据库匹配的MD5哈希值。
现在,在我的程序中,我有一个FileSystemWatcher,它应该监视用户打开的所有文件,但我似乎无法创建该函数,因为我不确定是否有在打开文件时为'path'声明文件的方法。
你怎么做?
请在下面留下任何问题,我会尽力与您讨论。我只是VB.net的初学者,所以我一直在努力寻找解决方案。
我尝试过:
在其他网站上提问。
As you can see in this code, an OpenFileDialog was used to declare the path of the file that is being checked to see if it has an MD5 hash matching a database of MD5 hashes.
Now, in my program, I have a FileSystemWatcher which is supposed to monitor all of the files being opened by the user, but I can't seem to be able to create that function, because I'm not sure if there's a way to declare the file for 'path' when it's being opened.
How do you do this?
Leave any questions below, and I'll do my best to talk to you about it. I'm only a beginner at VB.net, so I've been trying my best to find a solution to this.
What I have tried:
Asking questions on other sites.
推荐答案
这篇关于有没有办法在不使用openfiledialog打开变量的情况下为变量分配文件路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!