Valhalla Legends Forums Archive | Visual Basic Programming | two files loaded into one array

AuthorMessageTime
o.OV
Currently I load a single file into a byte array using the code below.

[code]
Open "Data1.txt" For Binary Access Read As #69
ReDim DataBase(LOF(69) - 1)
Get #69, , DataBase()
Close #69
[/code]

Now my objective is to append/load ANOTHER Data file to the array.

1. I want to avoid loops. (speed conscious)
2. I want to avoid using a secondary array. (the files are large)

Any ideas? Thanks in advance.
July 27, 2004, 11:00 AM
Tuberload
If you are really trying to be speed conscious, bypassing loops is not your solution. The solution would be to either use Random access to the file, or bypass VB and look into some disk IO API's. ReadFile, CreateFile, CloseHandle, SetFilePointer, might be something worth looking into.
July 27, 2004, 8:26 PM
o.OV
[quote author=Tuberload link=board=31;threadid=7911;start=0#msg72958 date=1090960016]
If you are really trying to be speed conscious, bypassing loops is not your solution. The solution would be to either use Random access to the file, or bypass VB and look into some disk IO API's. ReadFile, CreateFile, CloseHandle, SetFilePointer, might be something worth looking into.
[/quote]

I don't see how using Random access would help..
and I forgot all about APIs.
I already took a look at the ReadFile declaration and it looks promising.
Thanks.
July 28, 2004, 3:35 AM
Tuberload
[quote author=o.OV link=board=31;threadid=7911;start=0#msg73074 date=1090985722]I don't see how using Random access would help..[/quote]
Have you tested it? I did a test when I started helping Trust[e1] create his bots database and it was significantly faster than using Binary.

[quote]and I forgot all about APIs.
I already took a look at the ReadFile declaration and it looks promising.
Thanks.
[/quote]
Yes it is very promising. Hope it helps.
July 28, 2004, 6:35 PM
o.OV
[quote author=Tuberload link=board=31;threadid=7911;start=0#msg73121 date=1091039717]
[quote author=o.OV link=board=31;threadid=7911;start=0#msg73074 date=1090985722]I don't see how using Random access would help..[/quote]
Have you tested it? I did a test when I started helping Trust[e1] create his bots database and it was significantly faster than using Binary.
[/quote]

Did you load the database into memory or did you read a block at a time?
July 29, 2004, 3:48 AM
Tuberload
[quote author=o.OV link=board=31;threadid=7911;start=0#msg73200 date=1091072904]Did you load the database into memory or did you read a block at a time?
[/quote]

The testing only involved loading an entire file into memory using Binary access, Random access, and the API calls.

A roughly 4.5 mb file took:
-> Binary: 18967ms to read into memory
-> Random: 751ms
-> API: 321ms
July 29, 2004, 5:09 AM
Eli_1
Wow, that's a huge difference. :-\
July 29, 2004, 5:22 AM

Search