Avatar of jcm4101
jcm4101
Flag for Australia 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
Visual Basic.NETASP.NET

Avatar of undefined
Last Comment
jcm4101

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
nffvrxqgrcfqvvc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jcm4101

ASKER
Excellent work...
Thanks for the quick and complete solution.

D
jcm4101

ASKER
Actually, I'm a bit confused...

What's the correct way to call this class??

Ta
nffvrxqgrcfqvvc

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: 4884da7754823b44ccc2b2106f21146e
 

Debug.Print(FileChecksum.IntegrityCheck("c:\windows\system32\calc.exe"))

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
jcm4101

ASKER
Thanks  a lot..

Just sussed it out myself too  :-)

Greatly appreciated.

D