jcm4101
asked on
How to hash (MD5 or SHA1) a file with VB.NET
Hi experts..
I have a VB.NET application which imports a few csv files into a database nightly..
I need to ascertain if the file has changed from the previous nights import before I decide to import it or not.
I thought the easiest way would be to hash the file and store this hash in a table.
Then, each subsequent nightly import, I would simply hash the file, compare it with the hash of the file uploaded the previous night, if the hash's match, do nothing, if the hash's are different, perform the import..
So, can anyone poiont me in the right direction for hashing a file with VB.NET please??
Thanks in advance.
D
I have a VB.NET application which imports a few csv files into a database nightly..
I need to ascertain if the file has changed from the previous nights import before I decide to import it or not.
I thought the easiest way would be to hash the file and store this hash in a table.
Then, each subsequent nightly import, I would simply hash the file, compare it with the hash of the file uploaded the previous night, if the hash's match, do nothing, if the hash's are different, perform the import..
So, can anyone poiont me in the right direction for hashing a file with VB.NET please??
Thanks in advance.
D
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually, I'm a bit confused...
What's the correct way to call this class??
Ta
What's the correct way to call this class??
Ta
Whoops I forgot to show that part :(
It's basically just one shared method wrapped in class so it's similiar in respect to a module where you don't need to create an instance.
In the example below I used hashed the windows calculator on Windows 7: calc.exe MD5: 4884da7754823b44ccc2b2106f 21146e
It's basically just one shared method wrapped in class so it's similiar in respect to a module where you don't need to create an instance.
In the example below I used hashed the windows calculator on Windows 7: calc.exe MD5: 4884da7754823b44ccc2b2106f
Debug.Print(FileChecksum.IntegrityCheck("c:\windows\system32\calc.exe"))
ASKER
Thanks a lot..
Just sussed it out myself too :-)
Greatly appreciated.
D
Just sussed it out myself too :-)
Greatly appreciated.
D
ASKER
Thanks for the quick and complete solution.
D