|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Optimizing Binary File Inputfaster way then as follows (reading the file one lowly byte at a time)... Thanks for your time, Evan Public Function read_data(byVal FileName as String, byRef bytedata() as Byte) Dim File_Len as Long Dim Filenumber as Integer File_Len = FileLen(Filename) ReDim bytedata(File_Len) Filenumber = Freefile Open FileName For Binary Input As #Filenumber ' Open up the file Do ' Loop until there is no more data X = X + 1 Get #Filenumber, X, bytedata(X) Loop Until (EOF(Filenumber)) Close #Filenumber End Function > I'm reading data from a file into a Byte Array. Please tell me there's a Yup, just read it in one chunk:> faster way then as follows (reading the file one lowly byte at a time)... '*** Filenumber = FreeFile() Open FileName For Binary Access Read Lock Write As #Filenumber ReDim bytedata(0 To LOF(Filenumber) - 1) As Byte Get #Filenumber, , bytedata() Close #Filenumber '*** Hope this helps, Mike - Microsoft Visual Basic MVP - E-Mail: ED***@mvps.org WWW: Http://EDais.mvps.org/ Hi,
Mike D Sutton schrieb: >> I'm reading data from a file into a Byte Array. Please tell me there's a Or, if these byte data happens to be a sequence of singles:>> faster way then as follows (reading the file one lowly byte at a time)... > > Yup, just read it in one chunk: > > '*** > Filenumber = FreeFile() > Open FileName For Binary Access Read Lock Write As #Filenumber > ReDim bytedata(0 To LOF(Filenumber) - 1) As Byte > Get #Filenumber, , bytedata() > Close #Filenumber > '*** Dim arrSingles() As Single .... ReDim arrSingles(0 To (LOF(Filenumber) / 4 - 1)) Get Filenumber, , arrSingles .... -- Ulrich Korndoerfer VB tips, helpers, solutions -> http://www.proSource.de/Downloads/ ----------------------------------------------------------------------- Plea for a bright future for VB classic. Sign the petition to Microsoft: -> http://classicvb.org/petition/ ----------------------------------------------------------------------- |
|||||||||||||||||||||||