If the user uploads some file to my server and I want to make sure that the file hasn’t been changed from the last time the user uploaded it, how can I get this information?
I have a log table with User_id and FileName (the User_id is unique). I delete the file after I read the contents.
You can store a hash of the file before deleting it. To see if it is the same file being uploaded, compare the hash with the previous hash. You can do this with one of the HashAlgorithm classes in System.Cryptography, such as SHA1.
Here is some example code to get you started, assuming the variable
streamis a stream with your file data (you could useFileStreamto open it):Now, the variable
hashwill contain the hash, a fingerprint of the file contents. Even a small change (such as a single bit) will result in a different hash value, but taking the hash on the same file will always return the same hash.