ecov,
I think that the easiest way to do this at first would be to create a
structure which has fields that correspond to the different columns in the
fixed file format. The types of these fields would have the attributes on
them for marshaling to unmanaged code (it would have all the fixed length
strings declared properly as well).
Then, what you do is allocate a block of unmanaged memory the length of
one of your records. You call ReadFile (through P/Invoke), passing the
length of one record, and the address of this block of unmanaged memory.
You can then call Marshal.PtrToSt ructure to convert the structure into
managed code. If your record is composed of all blittable types (read, no
strings), then you can use unsafe code to make it even faster, to eliminate
the marshaling overhead.
Once you have the structure, you will have to put it in a dataset
yourself. You can probably name your structure's fields so that you can use
reflection to copy the rows over.
Finally, you would have to reverse the process to write it all back.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard. caspershouse.co m
"ecov" <e_*****@hotmai l.com> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.com...
Is there any easy way to read into a dataset a file that was created
from a BCP command. The file is in a fixed length format. I would
also like to be able to write out a dataset to the same type of file
structure.
The obvious solution would be to use XML file processing however that
is not an option as I have a third party vendor that is not capable of
processing XML files.
Thanks in advance