[RESOLVED] loading large files
i am using:
Code:
status.Caption = "loading file..."
filenum = FreeFile
Open Text1.Text For Binary As #filenum
strtext1 = Input(LOF(1), 1)
Close #filenum
to open a file for encryption, but the problem is, if i try and load large files and the computer does not have enough ram to do this then i get a few errors. i was thinking maybe i could split it up and load one chunk then encrypt that chunk and save it and then do the next chunk and save it to the end of the file so when it has done them all the file should be all together but i am not sure how to go about it. i am having trouble because i do not know how to tell visual basic to load, say, the first 10000000 characters of a file. does anyone know how i can do this? thanks.
Re: [RESOLVED] loading large files
Merri's code is exactly what I had in mind when I posted Friday. I used to write code like this back in the DOS days for installation programs. As you know, string memory was almost a joke back then so we had to break almost all the files into chunks and then copy them one chunk at a time.
So, your encryption requirement for monster files is quite similar, and Merri's approach will work very well. You have to check for file size usning FileLen()and if the file is smaller than your pre-defined chunk then you encrypt the whole file in one pass. But, if the chunk is smaller than the file, then you process one chunk at a time and finish it off with the residual chunk.
Re: [RESOLVED] loading large files
As final notes, the biggest file you can easily handle in VB6 is 2 GB. To bring that limit up to 4 GB, you have to convert FileLen's return value into a Currency (in a way that signed Long values are handled unsigned). However, NTSF can hold files that are bigger than 4 GB: adding support for files that big requires API or external libraries.