C#加载二进制文件 [英] C# loading binary files
问题描述
请告诉我最好/最快的方法:
Please show me the best/fast methods for:
1)将非常小的二进制文件加载到内存中。例如图标;
1) Loading very small binary files into memory. For example icons;
2)加载/读取大小为512Mb +的非常大的二进制文件。
2) Loading/reading very big binary files of size 512Mb+.
3)你的当你不想考虑大小/速度但必须做的事情时常见的选择:将所有字节读入内存?
3) Your common choice when you do not want to think about size/speed but must do only thing: read all bytes into memory?
谢谢!!!
PS对不起,也许是微不足道的问题。请不要关闭它;)
P.S. Sorry for maybe trivial question. Please do not close it;)
P.S.2。 镜像 Java的模拟问题;
P.S.2. Mirror of analog question for Java;
推荐答案
1:对于非常小的文件,File.ReadAllBytes没问题。
1: For very small files File.ReadAllBytes will be fine.
2:对于非常大的文件并使用.net 4.0,你可以使用MemoryMapped Files。
2: For very big files and using .net 4.0 , you can make use MemoryMapped Files.
3:如果不使用.net 4.0比,读取数据块将是不错的选择
3: If Not using .net 4.0 than , reading chunks of data would be good choice
这篇关于C#加载二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!