Saifallah
Saifallah

Reputation: 56

Copy a single large file (>100 MB)using the manual CreateFile()

I want to copy a single file, fairly large (+100MB) using CreateFile(), ReadFile(), and WriteFile().

My program successfully copied text file and other small file (in the range of KBs), but when I wanted to copy a 160 single .EXE file, it crashed and the debugger said "Stack overflow"

Upvotes: 0

Views: 655

Answers (2)

tojas
tojas

Reputation: 225

The simpler the better: int rc = system("copy foo.bin bar.bin");

Upvotes: 0

Philipp
Philipp

Reputation: 49812

Don't read the whole file at once, read it in smaller chunks (up to a few megabytes) instead.

Windows has several file copy functions that are already quite flexible, e.g. CopyFileEx, so consider using one of these functions instead.

Upvotes: 5

Related Questions