C#, C♯, C#相談室 Part43
■ このスレッドは過去ログ倉庫に格納されています
0217204
2007/10/08(月) 00:22:15これで60MBのファイルが600ミリ秒になったよ。
64KBずつ配列に読んで比較。
using (FileStream fs1=new FileStream(file1, FileMode.Open))
using (FileStream fs2 = new FileStream(file2, FileMode.Open))
{
if (fs1.Length != fs2.Length) return false;
int num = (int)fs1.Length;
byte[] data1 = new byte[num];
byte[] data2 = new byte[num];
int read;
while (true)
{
if (fs1.Position == fs1.Length) return true;
read = fs1.Read(data1, 0, 1024 * 64);
fs2.Read(data2, 0, 1024 * 64);
for (int i = 0; i < read; i++)
if (data1[i] != data2[i])
return false;
}
}
■ このスレッドは過去ログ倉庫に格納されています