J
John A Grandy
I am writing data to binary files one value at a time.
I am finding that when my code finishes , the final file is missing its
final value.
How can I ensure that all values have been written ?
Here is the code I call ( for each file ) :
FileStream stream = File.Open( <file path>, FileMode.Create,
FileAccess.Write, FileShare.ReadWrite );
BinaryWriter writer = new BinaryWriter( stream );
// write a whole bunch of doubles
writer.Write( <double value> );
writer.Flush(); // do I need this ?
writer.Close();
stream.Flush(); // do I need this ?
stream.Close(); // do I need this ?
stream.Dispose(); // do I need this ?
I am finding that when my code finishes , the final file is missing its
final value.
How can I ensure that all values have been written ?
Here is the code I call ( for each file ) :
FileStream stream = File.Open( <file path>, FileMode.Create,
FileAccess.Write, FileShare.ReadWrite );
BinaryWriter writer = new BinaryWriter( stream );
// write a whole bunch of doubles
writer.Write( <double value> );
writer.Flush(); // do I need this ?
writer.Close();
stream.Flush(); // do I need this ?
stream.Close(); // do I need this ?
stream.Dispose(); // do I need this ?