User-605707711 posted
Hello, I'm quite new to software developing (I'm used to web dev)
I tried to make process that monitores file for changes , makes its md5 hash and outputs.
Dim f As FileStream = New FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite, 8192) Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider md5.ComputeHash(f) Dim hash As Byte() = md5.Hash Dim buff As StringBuilder = New StringBuilder Dim hashByte As Byte For Each hashByte In hash buff.Append(String.Format("{0:X1}", hashByte)) Next Label1.Text = buff.ToString() System.Threading.Thread.Sleep(4000) f.Close()
|
This works perfectly.
but when i want to read changes all the time
Dim f As FileStream = New FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite, 8192) Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider Do md5.ComputeHash(f) Dim hash As Byte() = md5.Hash Dim buff As StringBuilder = New StringBuilder Dim hashByte As Byte For Each hashByte In hash buff.Append(String.Format("{0:X1}", hashByte)) Next Label1.Text = buff.ToString() System.Threading.Thread.Sleep(4000) Loop f.Close()
|
It doesn't output at all, it seams to freeze or smt.
I know Do Loop isn't right way to go with this problem, but i'm not a proffesional so I dont know any other way to make this work in background all the time.
Thank you !