I wrote a simple program in VB6 to copy all the files from a directory
on a CD-ROM to my hard disk. There are about 10 files, each about
30MB.
The program uses Get and Put to get data from the CD into a buffer and
then put it into the disk. See code below. It works, but it slows
down drastically before it copies all the files. Windows Task Manager
shows the CPU usage gradually increasing as the files are copied,
until it reaches 100 percent after about 6 files. That's when it
starts to get slow.
How can I prevent the CPU usage increasing? Here's the guts of the
code. All this is within another loop that goes through all the files
in sCDPath with Dir$. I've tried buffer sizes from 50000 to 2
million, makes no difference.
iCDFN = FreeFile
Open sCDPath & sFileName For Binary Access Read As #iCDFN
iDiskFN = FreeFile
Open sDiskPath & sFileName For Binary Access Write As #iDiskFN
Do
If lStartPos + lIncrement > lFileLen Then _
lIncrement = lFileLen - lStartPos + 1
sBuffer = String(lIncreme nt, " ")
Get #iCDFN, , sBuffer
Put #iDiskFN, , sBuffer
lStartPos = lStartPos + lIncrement
If lStartPos > lFileLen Then Exit Do
Loop
Close iCDFN
Close iDiskFN
TIA - Bryan Rickard
on a CD-ROM to my hard disk. There are about 10 files, each about
30MB.
The program uses Get and Put to get data from the CD into a buffer and
then put it into the disk. See code below. It works, but it slows
down drastically before it copies all the files. Windows Task Manager
shows the CPU usage gradually increasing as the files are copied,
until it reaches 100 percent after about 6 files. That's when it
starts to get slow.
How can I prevent the CPU usage increasing? Here's the guts of the
code. All this is within another loop that goes through all the files
in sCDPath with Dir$. I've tried buffer sizes from 50000 to 2
million, makes no difference.
iCDFN = FreeFile
Open sCDPath & sFileName For Binary Access Read As #iCDFN
iDiskFN = FreeFile
Open sDiskPath & sFileName For Binary Access Write As #iDiskFN
Do
If lStartPos + lIncrement > lFileLen Then _
lIncrement = lFileLen - lStartPos + 1
sBuffer = String(lIncreme nt, " ")
Get #iCDFN, , sBuffer
Put #iDiskFN, , sBuffer
lStartPos = lStartPos + lIncrement
If lStartPos > lFileLen Then Exit Do
Loop
Close iCDFN
Close iDiskFN
TIA - Bryan Rickard
Comment