Possible Duplicate:
Hash SHA1 large files (over 2gb) in C#
I have a large file in size of terms and it gives me error "Exception of type 'System.OutOfMemoryException' was thrown."
Anyone is having idea or solution for resolve this issue. Please help. Sample code....
private string GetSha1()
{
string filePath = txtFileName.Text;
byte[] filebytes = System.IO.File.ReadAllBytes(filePath);
byte[] hashValue;
SHA1Managed hashString = new SHA1Managed();
string hex = "";
hashValue = hashString.ComputeHash(filebytes);
foreach (byte x in hashValue)
{
hex += String.Format("{0:x2}", x);
}
return hex;
}
I am getting exception at line below in above code....
byte[] filebytes = System.IO.File.ReadAllBytes(filePath);
The filePath is having file which is having size > 500MB.