I am writing a class to wrap a RIFF file, so i have to read and decode some
structured data on the file.
For example, in the begining of file is a header:
Public Structure RiffHeader
Public id As Int32 ' (a FOURCC actually)
Public fileSize As Int32
Public fileType As Int32
End Structure
How can a I read from the file into a RiffHeader structure?
Regards, Alejandro Lapeyre 5 3315
Public Sub GetHeaderInfo(ByRef myHeader As RiffHeader)
Dim myFile As Integer
Dim i As Integer
myFile = FreeFile
Open "aFileName.riff" For Random Access Read _
As myFile Len = len(RiffHeader) // or is it sizeOf()?
Get myFile, 1, myHeader
Close myFile
End Sub -----Original Message----- I am writing a class to wrap a RIFF file, so i have to
read and decode somestructured data on the file.
For example, in the begining of file is a header:
Public Structure RiffHeader Public id As Int32 ' (a FOURCC actually) Public fileSize As Int32 Public fileType As Int32 End Structure
How can a I read from the file into a RiffHeader
structure?
Regards, Alejandro Lapeyre
.
* <an*******@discussions.microsoft.com> scripsit: Public Sub GetHeaderInfo(ByRef myHeader As RiffHeader) Dim myFile As Integer Dim i As Integer
myFile = FreeFile Open "aFileName.riff" For Random Access Read _ As myFile Len = len(RiffHeader) // or is it sizeOf()? Get myFile, 1, myHeader Close myFile End Sub
That's VB6 code, isn't it? In VB.NET you will have to use 'FileOpen',
'FileGet', 'FileClose' and so on.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Thank you for your time.
I am looking for the ".NET way" to do it. (no VB specifics libraries).
I am using IO.FileStream and it reads into a Bytes() as byte buffer. How can
i move this bytes into a structure?
Do I have to look in serialization?
Thank you, again. :-)
Regards,
Alejandro Lapeyre
Thanks for your time!
I was looking for a "standard .NET way" to do it.
Finaly, i have a working class using a FileStream and a BinaryReader, I fill
the structure using the BinaryReader.ReadInt32 and ReadChar methods.
Is there any other way to fill a structure from a some Bytes()?
Regards,
Alejandro Lapeyre
* "Alejandro Lapeyre" <no*********************@hotmail.com> scripsit: I was looking for a "standard .NET way" to do it.
Finaly, i have a working class using a FileStream and a BinaryReader, I fill the structure using the BinaryReader.ReadInt32 and ReadChar methods.
Is there any other way to fill a structure from a some Bytes()?
I don't think so. But why not use VB.NET's methods for doing that?
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Van Altena via .NET 247 |
last post by:
I'm trying to figure out how to read a formatted binary file intoa structure definition in C#. I've tried using the"StructLayout" attribute with both LayoutKind.Explicit andLayoutKind.Sequential...
|
by: Vasilis Serghi |
last post by:
Hi all, I am fairly new to C programming and I have come to a stand still. I
am trying to create a program that will accept a user input and give the
user an output depending on the contents of a...
|
by: Dave Coate |
last post by:
Hello again,
I am going to re-post a question. I got some excellent suggestions from
Rob and Mattias on this but their ideas did not solve the problem. Here is
the original post:
...
|
by: Eric |
last post by:
Hi,
I need to send data from a file into a structure. In Vb6 this was done like
so.
public Type Struct1
v1 as string
v2 as string
end type
|
by: a |
last post by:
I have a struct to write to a file
struct _structA{
long x;
int y;
float z;
}
struct _structA A;
//file open
write(fd,A,sizeof(_structA));
//file close
| |
by: brendon |
last post by:
I need to read in a jpeg or bmp file in to memory and then save these files in to a resource file for distribution in a form other than jpeg or bmp. This requires only one file to be distributed, the...
|
by: waffle.horn |
last post by:
Hi,
if this makes sense i want to create a function that can be called so
that it reads a single line from a file, then after using the
information destroys it. Such that when the function is...
|
by: Hollywood |
last post by:
Hello members of the comp.lang.c++,
My log file is made of a set of 1000 following lines kind:
21/09/07 13:49:56,MW.SET.D_IGLS,2.000000
21/09/07 13:49:56,MW.SET.GNP_NT,7.000000
.....
...
|
by: zl2k |
last post by:
hi, there
I have a appendable binary file of complex data structure named
data.bin created by myself. It is written in the following format:
number of Data, Data array
Suppose I have...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |