Feb 1st, 2006, 06:38 PM
#1
Thread Starter
Member
how to read any file
hello everybody
i try to read a file with input function but it works only with files that contains regular characters
if i want to read a mid file with this code:
VB Code:
Dim filetext, filename As String
filename = Dlg.filename
Open filename For Input As #1
filetext = Input(LOF(1), #1)
Close #1
It give error: input past end of file
why?
Feb 1st, 2006, 06:39 PM
#2
Re: how to read any file
The error means its treating one of the unknown characters as an End of File pointer... But, the end of the file hasn't been reached according to the total length.
Common error. Not worked out how to get round it yet though.
Feb 1st, 2006, 06:45 PM
#3
Thread Starter
Member
Re: how to read any file
excuse me i'm italian there is or not a solution?
i could try with file system object
Feb 1st, 2006, 06:46 PM
#4
Re: how to read any file
Wait for the more experienced members around here to give you a hand, i can't think of an easier or better way to handle displaying a file with unknown characters.
But, maybe they can
Feb 1st, 2006, 06:51 PM
#5
Re: how to read any file
work around,
VB Code:
Dim filetext As String
Dim filename As String
Dim sBuff As String
filename = Dlg.filename
Open filename For Input As #1
Do While Not EOF(1)
Line Input #1, filetext
sBuff = sBuff & vbNewLine & filetext
Close #1
Loop
Feb 1st, 2006, 07:20 PM
#6
Thread Starter
Member
Re: how to read any file
it work only with text files because when i view the lenght of sBuff, it is different from lenght of file.
the variable was trimmed.
it doesn't show all characters
for ex:
the file was 91440 characters
in the sBuff there are 6163 characters
Feb 1st, 2006, 07:49 PM
#7
Re: how to read any file
I forget who posted this, but it should solve the problem.
Attached Files
Feb 1st, 2006, 07:50 PM
#8
Re: how to read any file
I would try reading in the binary mode.
For instruction on how to do this, please see the tutorial on my site. On this page:
http://www.thevbprogrammer.com/tutorials.html
Check out "Binary Files" under "6. Files".
"It's cold gin time again ..."
Check out my website
here .
Feb 1st, 2006, 08:43 PM
#9
Re: how to read any file
also have a look at my sig for thw api method.
Feb 2nd, 2006, 04:42 AM
#10
Thread Starter
Member
Re: how to read any file
i've tryed also that program "read buffer" but it doesn't work
i want to retrive every single charaters from a Midi files.
before i had vb.net but i've lost it
in vb.net reading working.
Feb 2nd, 2006, 05:20 AM
#11
Re: how to read any file
MIDI files are binary. That's the only way to read them.
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