c#搜索vs读取
为什么缓慢地读取文件进行查找更好c#搜索vs读取,c#,performance,file,seek,C#,Performance,File,Seek,为什么缓慢地读取文件进行查找更好 //if (!read_fields[x] || !ok) //{ // if (l > 0) Seek(l, SeekOrigin.Current); // read[x] = null; // continue; //}
//if (!read_fields[x] || !ok)
//{
// if (l > 0) Seek(l, SeekOrigin.Current);
// read[x] = null;
// continue;
//}
byte[] bx = new byte[l];
if (l > 0) Read(bx, 0, l);
if (!read_fields[x] || !ok)
{
read[x] = null;
continue;
}
我的速度测试显示搜索速度非常慢 -将此流的当前位置设置为给定值。
-从流中读取字节块,并将数据写入给定的缓冲区
因此,使用seek重新定位读取位置-这是一个耗时的过程。如果是简单读取,则按顺序读取文件。请参阅: