阅读二进制文件 [英] Reading Binary Files

查看:110
本文介绍了阅读二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将一个大的二进制文件拆分成两个二进制文件。我在二进制文件中有一个分隔符

(比如NewLine)。我需要拆分二进制文件,使得第一个文件到达NewLine,第二个文件来自NewLine,结束文件的
。请告知我这是否可能


谢谢

Rohith

I need to split a large binary file into two binary files. I have a delimiter
(say NewLine) in the binaryfile. I need to split the binary file such that
the first file is upto the NewLine and the Second file is from NewLine to end
of file. Kindly let me know whether this si possible

Thanks
Rohith

推荐答案



" Rohith" <滚装**** @ discussions.microsoft.com>在消息中写道

新闻:BD ********************************** @ microsof t.com ...

"Rohith" <Ro****@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
我需要将一个大的二进制文件拆分成两个二进制文件。我在二进制文件中有一个
分隔符(比如NewLine)。我需要拆分二进制文件,以便第一个文件到达NewLine,第二个文件从NewLine到文件的结尾。请告诉我这是否可能
I need to split a large binary file into two binary files. I have a
delimiter
(say NewLine) in the binaryfile. I need to split the binary file such that
the first file is upto the NewLine and the Second file is from NewLine to
end
of file. Kindly let me know whether this si possible




只需打开一个针对该文件的System.IO.FileStream。通过块[

将它读出来一个byte []并检查你的分隔符的块。把块子

写成第一个然后是一个seconde FileStream。


David



Just open a System.IO.FileStream against the file. Read it out by chunks
into a byte[] and examine the chunks for your delimeter. Write the chunks
to a first and then a seconde FileStream.

David


Ya。这会奏效。但我有一个巨大的二进制文件近1GB。是否有一个

备用解决方案来查找分隔符位置,并检查每个

块通过它循环


David Browne ;写道:
Ya..This will work. But I have a huge binary file nearly 1GB. Is there an
alternate solution to find the delimiter position with checking on every
chunk looping through it

"David Browne" wrote:

Rohith <滚装**** @ discussions.microsoft.com>在消息中写道
新闻:BD ********************************** @ microsof t.com。 ..

"Rohith" <Ro****@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
我需要将一个大的二进制文件拆分成两个二进制文件。我在二进制文件中有一个
分隔符(比如NewLine)。我需要拆分二进制文件,以便第一个文件到达NewLine,第二个文件从NewLine到文件的结尾。请告诉我这是否可能
I need to split a large binary file into two binary files. I have a
delimiter
(say NewLine) in the binaryfile. I need to split the binary file such that
the first file is upto the NewLine and the Second file is from NewLine to
end
of file. Kindly let me know whether this si possible



只需打开一个针对该文件的System.IO.FileStream。通过块读取它到一个字节[]并检查你的分隔符的块。把块打成
到第一个然后是一个seconde FileStream。

大卫



Just open a System.IO.FileStream against the file. Read it out by chunks
into a byte[] and examine the chunks for your delimeter. Write the chunks
to a first and then a seconde FileStream.

David



对不起,没有循环遍历每一块数据。
Sorry, without looping through every chunk of data.


这篇关于阅读二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆