Lendo arquivo grande usando byte [] dá erro [duplicado]
Duplicata Possível:
Hash SHA1 arquivos grandes (mais de 2gb) em c #
Eu tenho um arquivo grande em tamanho de termos e isso me dá erro "Exceção do tipo 'System.OutOfMemoryException' foi lançada."
Qualquer pessoa está tendo ideia ou solução para resolver esse problema. Por favor ajude. Código de amostra....
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;
}
Estou recebendo exceção na linha abaixo no código acima ....
byte[] filebytes = System.IO.File.ReadAllBytes(filePath);
O filePath está tendo arquivo que está tendo tamanho> 500MB.