I have a very large binary file saved from a vb array with 2 dimensions; - Dim arMatrix() As Byte
-
Dim fNum As Integer
-
ReDim arMatrix(7166, 17769)
-
-
'code here to store data from a database into this
-
'array
-
-
'get a free file number
-
fNum = FreeFile()
-
-
'open the binary file
-
Open strMatrix For Binary As #fNum
-
-
'store the matrix array
-
Put #fNum, , arMatrix
-
Close #fNum
When I read the binary data back into the array it works. (i check the data against a database which was the origin of the binary file) -
Dim arMatrix() As Byte
-
Dim fNum As Integer
-
ReDim arMatrix(7166, 17769)
-
-
fNum = FreeFile
-
Open "C:\Data\matrix" & Format(lngMatrix, "00") & ".bin" For Binary As #fNum
-
Get #fNum, , arMatrix
-
Close #fNum
If, instead of a bi-dimensional array, I read this file into a single dimension array with 7167 * 17770 elements the code works but the data is not in the right order. - Dim arMatrix() As Byte
-
Dim fNum As Integer
-
ReDim arMatrix((7167 * 17770) - 1)
-
-
fNum = FreeFile
-
Open "C:\Data\matrix" & Format(lngMatrix, "00") & ".bin" For Binary As #fNum
-
Get #fNum, , arMatrix
-
Close #fNum
This wrong order also appears when I try to read the same binary data into a c++ array as in: - void CMFCNetflixDlg::OntxtTestMatrix()
-
{
-
ifstream f ("C:\\Data\\matrix01.bin", ios::in | ios::binary);
-
streambuf * fb;
-
int counter;
-
fb = f.rdbuf();
-
-
char **arMatrix;
-
arMatrix = new char *[7167] ;
-
for( int i = 0 ; i < 7167 ; i++ )
-
arMatrix[i] = new char[17770];
-
-
char buff[2];
-
char title[10];
-
-
for (counter = 0; counter < 7167; counter++) {
-
-
fb->sgetn(reinterpret_cast<char *>(arMatrix[counter]), 17770);
-
-
}
-
-
f.close();
-
-
//testing the order of bytes
-
for (i = 0; i < 17770; i++) {
-
if ((arMatrix)[0][i]) {
-
itoa((int)(arMatrix)[0][i], buff, 10);
-
itoa(i, title, 10);
-
MessageBox(buff, title);
-
}
-
}
-
delete [] arMatrix;
-
-
}
Any ideas on how to open this file so that the bytes are in the right order?
Thanks
1 2314 Banfa 9,065
Recognized Expert Moderator Expert
Clearly vB is writing the data of a 2 dimensional arry to the file in a strange order.
I would say that you options are
1. Work out what that strange order is an write some code to read the file contents into the single dimensioned buffer correctly.
2. Alter the code that writes the data so that instead of writing the entire array it writes individual entries in the arry in an order specified by yourself (and therefore readable by yourself).
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Arnold |
last post by:
I need to read a binary file and store it into a buffer in memory (system
has large amount of RAM, 2GB+) then pass it to a function. The function
accepts input as 32 bit unsigned longs (DWORD). I can pass a max of 512
words to it at a time. So I would pass them in chunks of 512 words until the
whole file has been processed. I haven't worked with binary files before so
I'm confused with how to store the binary file into memory. What sort of...
|
by: rob |
last post by:
hey every1,
I've got alot of data to write out to file and it's all just 1's and
0's.
It's all stored in 2 dimensional arrays of width 32 and varying
height.
At the moment it's all just integer arrays and the individual 1's and
0's are being written out as integers.
|
by: Yeow |
last post by:
hello,
i was trying to use the fread function on SunOS and ran into some
trouble.
i made a simple test as follows:
i'm trying to read in a binary file (generated from a fortran code)
that contains the following three floating-point numbers:
1.0 2.0 3.0
|
by: Jens Mittag |
last post by:
Hi!
In my code, I have an array of a structure, which I want to save to a
binary file. When the array is just created, everything works fine, but
when I change contents of the array, saving results in a file, which
doesn't hold the information of the changed array anymore. I dont know why.
Here is the code:
/*
|
by: John Dann |
last post by:
I'm trying to read some binary data from a file created by another
program. I know the binary file format but can't change or control the
format. The binary data is organised such that it should populate a
series of structures of specified variable composition.
I have the structures created OK, but actually reading the files is
giving me an error. Can I ask a simple question to start with:
I'm trying to read the file using the...
| |
by: Mark |
last post by:
Hello.
I am attempting to write binary data from a file to an
OLE Object field, and then write the file back out from
the database. I am reading and writing the files in
binary mode, and using GetChunk and AppendChunk to read
and write binary data from the OLE Object field. I am
using VBA and DAO for this experiment. The OLE Object
field is being used to store Long Binary data.
|
by: Edvin |
last post by:
Why is binary array written to a file different
than when converting the binary array to string
and then writing it to file! For example:
// --- Allocate byte array
byte arrByte = new byte;
for( int i=1; i< arrByte.Length; i++ )
arrByte = (byte)i;
|
by: nguser3552 |
last post by:
Hello Everyone,
I have a problem I can't surmount, anything is gravy at this point.
I need to be able to read any type of file .ext (mov,mpeg,mp3,etc) in binary
format. I can do this in C, but have to use:
int main(int argc,char** argv)
which is archaic.
My compiler is Visual Studio 5.0 Pro.
To make my dilemma as clear as possible:
|
by: dm3281 |
last post by:
Hello, I have a text report from a mainframe that I need to parse.
The report has about a 2580 byte header that contains binary information
(garbage for the most part); although there are a couple areas that have
ASCII text that I need to extract. At the end of the 2580 bytes, I can read
the report like a standard text file. It should have CR/LF at the end of
each line.
What is the best way for me to read this report using C#. It is...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |