在二进制模式下可以逐位写入吗? [英] Is it possible to write bit by bit while in Binary Mode?

查看:41
本文介绍了在二进制模式下可以逐位写入吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Gang,

我想知道如何将一个位写入文件(如果可能的话,那就是
)。我想重复写一个1或0作为数据我是 b $ b试图保存会指示。

先谢谢你的例子或解释,

Christian Blackburn

Hi Gang,
I would like to know how to write a single bit to a file (if that''s
possible). I would like to repetitiously write a 1 or 0 as the data I''m
trying to save would dictate.
Thanks in Advance for an example or explanation,
Christian Blackburn

推荐答案

嗨Cristan

是的你可以写一点文件,但是当你的意思是1/8字节而不是

时,它是不可能的。
Hi Cristan
Yes you can write a little bit to a file, but when you mean 1/8 byte than
it''s impossible.
我想知道如何将一个位写入文件(如果那个'' s
可能)。我想重复写一个1或0作为我想要保存的数据。
I would like to know how to write a single bit to a file (if that''s
possible). I would like to repetitiously write a 1 or 0 as the data I''m
trying to save would dictate.



我希望这有助于1/8字节。

Cor


I hope this helps a 1/8 byte.
Cor


只是为了添加Armin的建议,你还需要写出数据的长度

到某个地方的文件(第一个字节??),读取这个,然后从文件的其余部分读取相关的

位数据。


" Armin Zingler < AZ ******* @ freenet.de>在消息中写道

news:Op ************* @ tk2msftngp13.phx.gbl ...
Just to add to Armin''s suggestion, you need to also write the length of data
to the file somewhere(first byte??), read this and then read the relevent
bits of data from the remainder of the file.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:Op*************@tk2msftngp13.phx.gbl...
" Christian Blackburn" <基督教@该死@ SP ** @ Hotmail.com> schrieb
"Christian Blackburn" <Christian@Damn@Sp**@Hotmail.com> schrieb
嗨Gang,
我想知道如何将一个位写入文件(如果
那可能)。我想重复写一个1或0作为我试图保存的数据。
先谢谢你的例子或解释,
Christian Blackburn
正如Cor所说,不可能写一个位。您可以使用
Boolean-Array作为包含8个值的缓冲区。将缓冲区包装在一个类中,
添加一个Write方法,在缓冲区的下一个位置写入传递的位(由布尔值表示)
Hi Gang,
I would like to know how to write a single bit to a file (if
that''s possible). I would like to repetitiously write a 1 or 0 as the
data I''m trying to save would dictate.
Thanks in Advance for an example or explanation,
Christian Blackburn
As Cor stated, it is not possible to write a single bit. You could use a
Boolean-Array as a buffer containing 8 values. Wrap the buffer in a class,
add a Write method that writes the passed bit (represented by a Boolean)



并增加缓冲区指针。当写入8位时,从8位创建一个字节并将字节
写入文件。

我不知道它是否有意义。小心,因为写10位时会丢失2位。 ;-))

-
Armin


at the next position in the buffer and increases the buffer pointer. When 8
bits have been written, create a byte from the 8 bits and write the byte to the file.

I don''t know if it makes sense. Be careful because 2 bits will be losted
when writing 10 bits. ;-))
--
Armin



你好,


Christian Blackburn <基督教@该死@ SP ** @ Hotmail.com> schrieb:
Hello,

"Christian Blackburn" <Christian@Damn@Sp**@Hotmail.com> schrieb:
我想知道如何将一个位写入文件(如果可能的话)。


你只能写字节。

我想重复写一个1或0作为我试图保存的数据请求。
I would like to know how to write a single bit to a file (if that''s
possible).
You can only write bytes.
I would like to repetitiously write a 1 or 0 as the data I''m
trying to save would dictate.




你可能想看看''BitArray''类。


-

Herfried K. Wagner

MVP·VB Classic,VB.NET
http://www.mvps.org/dotnet


这篇关于在二进制模式下可以逐位写入吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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