C# - 读取一个文件的特定字节 [英] c# - Read specific bytes of an file
本文介绍了C# - 读取一个文件的特定字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法从文件中读取特定字节?
Is there any way to read specific bytes from an file?
例如,我有以下的代码读取该文件的所有字节
For example, I have the following code to read all the bytes of the file
byte[] test = File.ReadAllBytes(file);
我想读从偏移50字节,以抵消60,并把它们放入数组。
I want to read the bytes from offset 50 to offset 60 and put them in an array.
推荐答案
LINQ版本:
byte[] test = File.ReadAllBytes(file).Skip(50).Take(10).ToArray();
这篇关于C# - 读取一个文件的特定字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文