I had to write a custom download component to download modules for a ClickOnce deployed application. The actual downloading is simple, the tricky part was creating the manifest and make sure that I only download files that are required.
I am using an GeneraApplicationManifest MSBuild task to generate an application manifest. The documentation is very easy to follow.
The generated manifest will include a Hash value. It is fairly simple to compute the same hash value manually and be able to validate it.
private bool HashChanged(string fileName, string originalHashValue)
byte Hash = Convert.FromBase64String(originalHashValue));
SHA1Managed sha = new SHA1Managed();
FileStream strm = null;
strm = new FileStream(fileName, FileMode.Open, FileAccess.Read);
newHash = sha.ComputeHash(strm);
if (strm != null)
if (Hash.Length != newHash.Length)
for(int i = 0; i< Hash.Length; i++)
if (Hash[i] != newHash[i])
Cross Posted from http://blog.tfanshteyn.com/2007/12/calculating-hashvalues-for-files-way.html