Page 1 of 1
Read large file in small bytes
Posted: Tue Jul 20, 2010 8:42 pm
by Krisko
Hi all I'm wondering if I have a large file for example a file that is 5gb large. Can I read it and write it in small bytes (e.g. a byte that is 100mb large) and how can I make this ? Thank you

Re: Read large file in small bytes
Posted: Tue Jul 20, 2010 9:02 pm
by ts-soft
Split file?
Code: Select all
EnableExplicit
Define.s BigFile = "c:\my big file.dat"
Define.s SmallFiles = "c:\my smallfile_"
Define.i BF, SF, length, count = 1, bufSize = 100 * 1024 * 1024
Define *buf = AllocateMemory(bufSize)
BF = ReadFile(#PB_Any, BigFile)
If BF
While Not Eof(BF)
length = ReadData(BF, *buf, bufSize)
If length
SF = CreateFile(#PB_Any, SmallFiles + Str(count))
count + 1
If SF
WriteData(SF, *buf, length)
CloseFile(SF)
EndIf
EndIf
Wend
CloseFile(BF)
FreeMemory(*buf)
EndIf
Re: Read large file in small bytes
Posted: Wed Jul 21, 2010 10:08 pm
by Krisko
Oh thank you very much but how can I combine splited files back in one file after I separete them in parts

Re: Read large file in small bytes
Posted: Wed Jul 21, 2010 10:33 pm
by ts-soft
write the first file, the second and so on and close the new file

Re: Read large file in small bytes
Posted: Wed Jul 21, 2010 11:35 pm
by Krisko
10x
