| | |
Reading a binary file in chunks...
![]() |
•
•
Join Date: Jul 2009
Posts: 1
Reputation:
Solved Threads: 0
Hi All,
Got a bit of a problem.
I have a COM Component for an ASP project that reads a binary file from a location on the HDD (could be from 60MB-200MB) and, with the response object found in ASP.DLL, sends the file in chunks of 96kb.
The aim was for me to create code that doesn't load the entire file into memory and then send it. But looking at the memory usage in task manager, it seemingly is loading a lot of data in -- memory usage skyrockets to about the size of the file and gradually reduces until the file is sent.
My question to the experts out there -- could you guys help me or give me some pointers to make this code read the file in "as required"? Like not all at once, only read the chunks when needed and send. Hope that makes sense!
Thank you very much for any help at all.
Got a bit of a problem.
I have a COM Component for an ASP project that reads a binary file from a location on the HDD (could be from 60MB-200MB) and, with the response object found in ASP.DLL, sends the file in chunks of 96kb.
The aim was for me to create code that doesn't load the entire file into memory and then send it. But looking at the memory usage in task manager, it seemingly is loading a lot of data in -- memory usage skyrockets to about the size of the file and gradually reduces until the file is sent.
My question to the experts out there -- could you guys help me or give me some pointers to make this code read the file in "as required"? Like not all at once, only read the chunks when needed and send. Hope that makes sense!
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim objFSO As New FileSystemObject Dim filePath As String filePath = "C:\filename here" If (objFSO.FileExists(filePath)) Then Set objFSO = Nothing Dim iFileNum As Integer Dim lBytesLeft As Long Dim B() As Byte iFileNum = FreeFile ReDim B(BUFF_SIZE - 1) Open filePath For Binary As iFileNum response.Buffer = True response.AddHeader "Content-Length", LOF(iFileNum) response.ContentType = "application/octet-stream" lBytesLeft = LOF(iFileNum) If (response.IsClientConnected) Then Do While (lBytesLeft > 0) If (lBytesLeft < BUFF_SIZE) Then ReDim B(lBytesLeft - 1) End If Get #iFileNum, , B() response.BinaryWrite B response.Flush Sleep 0.55 lBytesLeft = lBytesLeft - BUFF_SIZE Loop Else response.End End If Close iFileNum end if
Thank you very much for any help at all.
![]() |
Similar Threads
- Reading binary file(image) (C)
- Error when reading a binary file! (C++)
- Reading binary file without knowing file format (C)
- reading a binary file in C (C)
- Problems reading a Binary File more than 2.0 GB with VC++ (C++)
- fscanf and reading from binary file (C)
- Reading a Binary File to a C++ Class (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Counting Numbers inside text area
- Next Thread: About VB IF ELSE Statement
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





