gpt4 book ai didi

c# - 使用 byte[] 读取大文件会出错

转载 作者:行者123 更新时间:2023-11-30 18:55:05 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Hash SHA1 large files (over 2gb) in C#

我有一个很大的文件,它给了我错误“抛出了‘System.OutOfMemoryException’类型的异常。”

任何人都有解决此问题的想法或解决方案。请帮忙。示例代码....

 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;
}

我在上面代码的下面一行遇到异常....

   byte[] filebytes = System.IO.File.ReadAllBytes(filePath);

文件路径中的文件大小 > 500MB。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com