Click here to Skip to main content
15,896,330 members
Home / Discussions / C#
   

C#

 
GeneralRe: Error in WPF Pin
Pete O'Hanlon17-Jun-13 22:30
mvePete O'Hanlon17-Jun-13 22:30 
NewsRe: Error in WPF Pin
Nick_Frenk17-Jun-13 23:34
Nick_Frenk17-Jun-13 23:34 
GeneralRe: Error in WPF Pin
Pete O'Hanlon18-Jun-13 0:50
mvePete O'Hanlon18-Jun-13 0:50 
GeneralRe: Error in WPF Pin
Nick_Frenk18-Jun-13 2:33
Nick_Frenk18-Jun-13 2:33 
GeneralRe: Error in WPF Pin
Nick_Frenk19-Jun-13 3:13
Nick_Frenk19-Jun-13 3:13 
QuestionRead & Write Binary Data File Pin
Jassim Rahma16-Jun-13 9:34
Jassim Rahma16-Jun-13 9:34 
AnswerRe: Read & Write Binary Data File Pin
Pete O'Hanlon16-Jun-13 9:44
mvePete O'Hanlon16-Jun-13 9:44 
GeneralRe: Read & Write Binary Data File Pin
harold aptroot16-Jun-13 10:11
harold aptroot16-Jun-13 10:11 
Binary files don't have columns, just bytes. So you have to make up some sort of format (it can be a trivial format, of course, but it'll be a format).
The simplest format is to just dump everything row by row. That make the number, order and type of the columns part of the format, too. So you can't easily make changes to that.
A slight improvement on that is starting with an int specifying the number of rows, so the reader can pre-allocate instead of having to take a guess and maybe resize.
You might consider putting a version number in it too, it can't really hurt and your later self will probably thank you.

In most cases, it's most convenient to use the BinaryWriter (or BinaryReader for reading) class. Just iterate over the rows, and within a row, iterate over the columns, and write everything to the file.
On the read-side, be careful to read everything as the type it was written as (that's more of a guideline than a rule, sometimes there's a reason to read something as a different type).

At least, that's how I would do it. In my experience, using the built-in serialization leads to
0) bloat in the data file
1) type not being serializable, so you still have to do it manually, and this time the api sucks
2) extreme slowness
3) compatibility trouble between versions of your program even if the data format didn't need to change
In some cases it can be less work.
AnswerRe: Read & Write Binary Data File Pin
V.16-Jun-13 21:20
professionalV.16-Jun-13 21:20 
QuestionCustom gridview showing more rows than data Pin
Shelts15-Jun-13 7:10
Shelts15-Jun-13 7:10 
Questionmachine learning c# web service and web site Pin
miren gomez14-Jun-13 4:34
miren gomez14-Jun-13 4:34 
AnswerRe: machine learning c# web service and web site Pin
Pete O'Hanlon14-Jun-13 4:50
mvePete O'Hanlon14-Jun-13 4:50 
AnswerRe: machine learning c# web service and web site Pin
Alan Balkany14-Jun-13 4:59
Alan Balkany14-Jun-13 4:59 
AnswerRe: machine learning c# web service and web site Pin
Dave Kreskowiak14-Jun-13 7:28
mveDave Kreskowiak14-Jun-13 7:28 
GeneralRe: machine learning c# web service and web site Pin
miren gomez14-Jun-13 7:55
miren gomez14-Jun-13 7:55 
GeneralRe: machine learning c# web service and web site Pin
Pete O'Hanlon14-Jun-13 8:17
mvePete O'Hanlon14-Jun-13 8:17 
GeneralRe: machine learning c# web service and web site Pin
miren gomez14-Jun-13 8:36
miren gomez14-Jun-13 8:36 
GeneralRe: machine learning c# web service and web site Pin
NotPolitcallyCorrect14-Jun-13 8:49
NotPolitcallyCorrect14-Jun-13 8:49 
GeneralRe: machine learning c# web service and web site Pin
Pete O'Hanlon14-Jun-13 8:49
mvePete O'Hanlon14-Jun-13 8:49 
GeneralRe: machine learning c# web service and web site Pin
miren gomez14-Jun-13 9:01
miren gomez14-Jun-13 9:01 
GeneralRe: machine learning c# web service and web site Pin
Pete O'Hanlon14-Jun-13 9:03
mvePete O'Hanlon14-Jun-13 9:03 
GeneralRe: machine learning c# web service and web site Pin
miren gomez14-Jun-13 9:08
miren gomez14-Jun-13 9:08 
GeneralRe: machine learning c# web service and web site Pin
Pete O'Hanlon14-Jun-13 9:37
mvePete O'Hanlon14-Jun-13 9:37 
GeneralRe: machine learning c# web service and web site Pin
miren gomez14-Jun-13 9:42
miren gomez14-Jun-13 9:42 
GeneralRe: machine learning c# web service and web site Pin
Pete O'Hanlon14-Jun-13 9:48
mvePete O'Hanlon14-Jun-13 9:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.