|
-
Aug 29th, 2000, 02:11 PM
#1
Thread Starter
Frenzied Member
I want to read a file and
put it in a byte array.
Why wont it put it in the
array?
Code:
Dim StrFile as String
Dim bytTemp() As Byte
StrFile = "C:\readme.txt"
Open strFile For Binary As #1
Get #1, , bytTemp
Close #1
ReadMe.txt:
Code:
MainBoard : M599LMR
BIOS Date : Release 03/08/2000S
VGA : SiS Multimedia V1.08
Sound : Version 2.32
Modem : Pctel R7.64-pcc-06
Lan DAVICOM : Version 1.12
Gamut : Version 1.56
Super Voice : Version 2.2
Audio Rack : Version 2.32
[Edited by Evan on 08-29-2000 at 03:13 PM]
-
Aug 29th, 2000, 02:34 PM
#2
_______
<?>
Code:
Private Sub Command1_Click()
Dim StrFile As String
Dim bytTemp() As Byte
Dim i As Integer
StrFile = "C:\readme.txt"
Open StrFile For Binary As #1
Do Until EOF(1)
ReDim Preserve bytTemp(i)
Get #1, , bytTemp(i)
i = i + 1
Loop
Close #1
'for display only List1
For i = 0 To i - 1
List1.AddItem bytTemp(i)
Next
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 29th, 2000, 03:57 PM
#3
Fanatic Member
No offence HeSaidJoe, but that is the slowest possible way to read a file in, you also seem to be redimensioning the array as a variant, or does a dynamic array stay as the type it was originally declared as? Thats a good question.
Code:
Private Sub Command1_Click()
Dim StrFile As String
Dim bytTemp() As Byte
StrFile = "C:\readme.txt"
Open StrFile For Binary As #1
'redim the array to the size of the file
ReDim bytTemp(LOF(1) - 1) As Byte
'read the whole file in one go
Get #1, , bytTemp
'close the file
Close #1
End Sub
[Edited by Iain17 on 08-29-2000 at 05:02 PM]
Iain, thats with an i by the way!
-
Aug 29th, 2000, 04:20 PM
#4
Thread Starter
Frenzied Member
??
Ok..
That works .. all acept the
file im reading is going to
be about 100mbs sometimes.
How do I store it in a byte
varable with out it over flowing?
-
Aug 29th, 2000, 04:35 PM
#5
_______
<?>
No offence taken..I only adjusted what was given to make it work.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 29th, 2000, 04:46 PM
#6
Fanatic Member
Are you sure that is a good idea. 100mb file in memory. Can you not work with chunks of the file? That i think would be better idea. I just tried the code i gave you, and it loaded a 100mb file ok, took some time though.
Mind you i am running windows 2000, so it may not work on 98.
Iain, thats with an i by the way!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|