If (BytesWritten2 + BytesWritten) < BytesRead then WriteFile(ADestinationFile, Buffer, BytesRead - BytesWritten, BytesWritten2, nil) WriteFile(ADestinationFile, Buffer, BytesRead, BytesWritten, nil) If (not ReadFile(ASourceFile, Buffer, BufferSize, BytesRead, nil)) and (BytesRead = 0) then While (FileSize - FileSeek(ASourceFile, 0, FILE_CURRENT)) >= BufferSize do You can tune your own copy function more to fit your needs.īelow is my own buffered copy function (i've stripped out the GUI callbacks): procedure CustomFileCopy(const ASourceFileName, ADestinationFileName: TFileName) īufferSize = 1024 // 1KB blocks, change this to tune your speedīytesRead, BytesWritten, BytesWritten2: DWORD ĪSourceFile := OpenLongFileName(ASourceFileName, 0) įileSize := FileSeek(ASourceFile, 0, FILE_END) ĪDestinationFile := CreateLongFileName(ADestinationFileName, FILE_SHARE_READ) Because the windows API's are more tuned for overall best case (small files, large files, files over network, files on slow drives). If you know the kind of files your going to copy, the 3th method will normally outperform the others.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |