나는 서버 A에 1GB를 가지고 있는데, 로컬에 가져 오기 위해서는 Read()
메서드를 사용해야한다. 패키지 (16517 패키지)로 분할됩니다. 각 패키지는 65536 바이트의 헤더를 포함합니다.바이너리 파일에 byte []를 쓰는 가장 좋은 방법
현재 저는 각 패키지를 파일에 직접 작성하기 위해 BinaryWriter
을 사용합니다. 하지만 그것은 5 분 (323642 ms) 이상 걸렸습니다.
일부 패키지를 byte[]
으로 결합하려고 시도하지만 시간이 줄어들지 않습니다 (317397 ms).
byte[]
을 이진 파일에 쓰는 가장 좋은 방법은 무엇입니까?
업데이트
const ulong Memory_10MB = 10485760; // 10MB
do {
byte[] packetData = Read(&totalSize, /*Other parameters*/ ,&hasFollowing);
if (package == null) {
// Process error
return;
}
dataSize += (ulong)packetData.Length;
if (dataSize >= Memory_10MB)
{
if (binaryWriter == null)
{
path = Path.GetTempFileName();
fileStream = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Read);
binaryWriter = new BinaryWriter(fileStream);
if (responseData.Length > 5)
{
binaryWriter.Write(responseData.Skip(5).ToArray());
}
}
binaryWriter.Write(packetData);
}
else
{
responseData = Utilities.ConcatArrays(responseData, packetData);
}
} while (dataSize < totalSize);
// Process after got data
Windows Explorer를 사용하여 파일을 복사하는 경우 얼마나 걸리나요? 그것이 무엇이든 나는 당신이 그것에 대해 많이 향상시킬 것이라고 기대하지 않을 것입니다. –
데이터를 어떻게 작성하고 있습니까? 코드를 게시하십시오. –
먼저 출력 파일은 Temp 폴더에 있습니다. 다른 드라이브에 복사합니다. 약 3 초가 걸립니다. – GSP