473,504 Members | 13,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BinaryWriter.Write

// Example
BinaryWriter bw = new BinaryWriter(new
FileStream("c:\Test.bin",FileMode.Append));

BinaryWriter.Write writes data to the stream. However, it doesn't
automatically flush data any buffered data to the underlying device. What
determines *when* data is written to the underlying device, without calling
Flush function.

Thank you,
-Boris
Nov 16 '05 #1
5 15607
It is determined by the size of the internal buffer (I believe you can
modifiy its size).
Also the writer flushes if the file is closed. To ensure that files are
always closed use the using statement:

using (BinaryWriter bw = new BinaryWriter(new
FileStream("c:\Test.bin",FileMode.Append)))
{
// do stuff with file here
}
// file is automatically closed

"Boris" <bo***@crabel.com> schrieb im Newsbeitrag
news:uG**************@TK2MSFTNGP10.phx.gbl...
// Example
BinaryWriter bw = new BinaryWriter(new
FileStream("c:\Test.bin",FileMode.Append));

BinaryWriter.Write writes data to the stream. However, it doesn't
automatically flush data any buffered data to the underlying device. What
determines *when* data is written to the underlying device, without calling Flush function.

Thank you,
-Boris

Nov 16 '05 #2
Do you have an example on how to change size of internal buffer?

Thank you,
-Boris

"cody" <de********@gmx.de> wrote in message
news:e0**************@tk2msftngp13.phx.gbl...
It is determined by the size of the internal buffer (I believe you can
modifiy its size).
Also the writer flushes if the file is closed. To ensure that files are
always closed use the using statement:

using (BinaryWriter bw = new BinaryWriter(new
FileStream("c:\Test.bin",FileMode.Append)))
{
// do stuff with file here
}
// file is automatically closed

"Boris" <bo***@crabel.com> schrieb im Newsbeitrag
news:uG**************@TK2MSFTNGP10.phx.gbl...
// Example
BinaryWriter bw = new BinaryWriter(new
FileStream("c:\Test.bin",FileMode.Append));

BinaryWriter.Write writes data to the stream. However, it doesn't
automatically flush data any buffered data to the underlying device.
What
determines *when* data is written to the underlying device, without

calling
Flush function.

Thank you,
-Boris


Nov 16 '05 #3
Boris <bo***@crabel.com> wrote:
Do you have an example on how to change size of internal buffer?


Many of the FileStream constructors have a buffer size parameter. (The
BinaryWriter itself doesn't have a buffer, as far as I know.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

What is the default buffer size for FileStream?
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Boris <bo***@crabel.com> wrote:
Do you have an example on how to change size of internal buffer?


Many of the FileStream constructors have a buffer size parameter. (The
BinaryWriter itself doesn't have a buffer, as far as I know.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #5
Boris <bo***@crabel.com> wrote:
What is the default buffer size for FileStream?


That depends on what constructor is called. The docs specify for each
constructor. I think they're all 4K or 8K.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5115
by: Mark Miller | last post by:
I have a char array and when I write it to a file using BinaryWriter the position of the pointer is the size of the array + 1. For example: writing char leaves the pointer at position 26 after...
6
2973
by: ThunderMusic | last post by:
Hi, In my app, I open a file using a FileStream then pass it to a BinaryWriter. I then use the BinaryWriter instance to write to my file. But a problem arose : The file never gets bigger than 1kb....
3
3805
by: Peyman | last post by:
Hello all, This is my first c# program. And I seem to have a problem. Here is the code: FileStream myStream = new FileStream("d:\\test.txt", FileMode.Create, FileAccess.Write); BinaryWriter...
17
3778
by: Filip Strugar | last post by:
Considering that the BinaryWriter/BinaryReader object closes the underlaying stream upon being gc collected, is the following code correct, and if it is what is the reason preventing BinaryWriter...
1
6212
by: Claire | last post by:
I'm writing from a serial port into a MemoryStream via a BinaryWriter in my protocol object. After I've filled the memorystream, which is approx 200KB in size, I then pass it up to my datahandler...
3
1787
by: Eugene | last post by:
I'm trying to write a class which uses BinaryWriter as its base but allows for queuing of write requests Public Class QueuedBinaryWriter Inherits BinaryWriter I override all the Write methods...
5
1496
by: Travis Llewellyn | last post by:
I am writing a program that write out and array that I have stored. It writes out the whole array but adds a Carrot "^" in front of each section it writes. If I do a debug.writeline(hello) it...
3
6616
by: =?Utf-8?B?ZnVuZG9vX2ty?= | last post by:
Check the following code ///Buffer to store the data byte data = new byte; ///Create a memory stream from the buffer MemoryStream memStream = new MemoryStream(data); ///Binary writer...
1
2011
by: ShapeMan | last post by:
I'm trying to export data to a binary file. I have imported the data from a binary file using BinaryReader and everything works as I would have expected. The data after importing is a variety of...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.