C# 调查结果;“空的”;文件中的部分
编辑1: 我构建了一个torrent应用程序;同时从不同的客户端下载。每个下载代表我的文件的一部分,不同的客户端有不同的部分。 下载完成后,我需要通过在我的文件中查找“空”部分来知道我现在需要完成的部分 创建固定大小文件的一种方法:C# 调查结果;“空的”;文件中的部分,c#,file,C#,File,编辑1: 我构建了一个torrent应用程序;同时从不同的客户端下载。每个下载代表我的文件的一部分,不同的客户端有不同的部分。 下载完成后,我需要通过在我的文件中查找“空”部分来知道我现在需要完成的部分 创建固定大小文件的一种方法: File.WriteAllBytes(@"C:\upload\BigFile.rar", new byte[Big Size]); BitArray TorrentPartsState = new BitArray(10); 将我的文件表示为部分的我的部分Ar
File.WriteAllBytes(@"C:\upload\BigFile.rar", new byte[Big Size]);
BitArray TorrentPartsState = new BitArray(10);
将我的文件表示为部分的我的部分Arr:
File.WriteAllBytes(@"C:\upload\BigFile.rar", new byte[Big Size]);
BitArray TorrentPartsState = new BitArray(10);
例如:
File.WriteAllBytes(@"C:\upload\BigFile.rar", new byte[Big Size]);
BitArray TorrentPartsState = new BitArray(10);
文件大小为100
TorrentPartsState[0] = true; // thats mean that in my file, from position 0 until 9 I **dont** need to fill in some information.
TorrentPartsState[1] = true; // thats mean that in my file, from position 10 until 19 I **need** to fill in some information.
我找到了一种有效的方法来保存BitArray包含的内容,即使计算机/应用程序已关闭。我想到的一种方法是通过xml文件,并在每次完成一部分时更新它
我认为这不是一个明智而有效的解决方案。有其他的想法吗?在你的文件中实现一个文件系统(比如在磁盘上)——只需使用一些简单的,应该是FOS竞技场上可用的东西,你可以使用一个(in-system.Collections)
然后,当访问文件中的偏移量时,可以将该偏移量处的位数组设置为true
因此,对于10000字节的文件:
BitArray ba = new BitArray(10000);
// Visited offset, mark in the BitArray
ba[4] = true;
当您开始转账时,您似乎知道以下几点:
- 控制文件可以定义要传输的段,例如16MB块,并由寻找不完整段的线程和从中检索该段的合适服务器将其视为工作队列
- 控制文件可以是结果文件中的一个单独分支。(我在跟谁开玩笑?)