【发布时间】:2011-11-19 10:28:37
【问题描述】:
这比什么都更适合练习,真的。我对此感到最沮丧,因为这对我来说是一个相当新的概念。我将在下面发布我的代码。
我正在尝试做的事情:
- 将文件读入字节数组
- 将字节拆分为预定义大小的部分
-
将零件重新组合在一起,然后将文件写入 HD
byte[] sData = File.ReadAllBytes(@"C:\Project1.exe"); // 16,384 字节
// Split the data up here int range = 8; range *= 1024; int pos = 0; int remaining; int i = 0; byte[] test = null; while ((remaining = sData.Length - pos) > 0) { byte[] block = new byte[Math.Min(remaining, range)]; test = new byte[block.Length + pos]; Array.Copy(sData, pos, test, pos, block.Length); pos += block.Length; i++; } File.WriteAllBytes(@"C:\blank.exe", test);
文件“blank.exe”总是损坏。
有人在这里看到我的错误吗?
我很感激,埃文
【问题讨论】:
-
最好把你的问题留在上面,这样下一个在谷歌上搜索同样问题的人就不必问了。
-
你原来的问题在哪里?