Reading a Binary File into a DataGrid

Reading a Binary File into a DataGrid

Post by Mike Parke » Sun, 24 Nov 2002 00:45:49



Hi all,

I have some binary files that I'm reading into C#.  The
files have a table format with column names that I can
read, but each file may have a different number of columns.

I am trying to write a generic file viewing form that will
open one of these files and display the contents in a
datagrid.

I have tried creating an ArrayList of ArrayLists of the
data and binding this to the datagrid, but the results
were amusing: I get columns titled IsReadOnly, SyncRoot,
IsSynchronized, etc.  All properties of an ArrayList.

I know that if I could create ArrayLists of objects with
each object representing a row from my binary file, it
would display correctly, but unfortunately I don't know
the format of the binary file ahead of time.

I suppose I could do something fancy, like create a class
on the fly that corresponds to the format of the file,
then create an ArrayList of objects of this type, but it
seems to me that shouldn't be necessary.

Is there a simple way to do this?

Thanks in advance,

mp

 
 
 

1. Problems with Japanese strings and binary files in a Japanese environment

I developed a application that have been translated to Japanese (messages
and screens) and I started getting serious problems and the English version
works perfectly.

1. I have a variable with Japanese characters and if I do debug.print
Variable the content of the variable is printed perfectly if I do
Object.Print Variable the content gets to the printer all trashed and the
problem is not with the printer driver.

2. I have a file that I receive in perfect conditions I open it in binary
mode I read it and I save it in another file that I open in binary mode and
the second file gets all trashed. Code:

 Open file1 For Binary Access Read Lock Read As #1
 WBuffer=LOF(1)
 Open File2 For Binary Access Write Lock Read As #2

  'Write to the file
   Do While WBuffer > 20000
      WWriteBuffer = Input(20000, #1)
      Put #2, , WWriteBuffer
      WBuffer = WBuffer - 20000
   Loop
   WWriteBuffer = Input(WBuffer, #1)
   Put #2, , WWriteBuffer

Any suggestions?

Thanks,

2. Address already exists

3. Attachments come into exchange as binary file

4. Front-end Exchange server

5. Need Help on reading EDB echange 5.5 Log file files

6. No Sites in Organization Address Book

7. Propulating .NET datagrid via webdav

8. sent items never going away

9. WebDAV, DotNEt Datagrids and Checkbox

10. How to format DataGrid Columns

11. CheckBox in DataGrid

12. refreshing a datagrid.

13. Date formatting using data formatting expression in datagrid