Article

How can I perform a Copy­File in unbuffered mode?

The Old New Thing ·The Old New Thing ·Published 2026-08-10 ·5 min read

This article discusses how to use the Copy­File­Ex and Copy­File2 functions in Windows to copy files in unbuffered mode by utilizing specific flags. It explains the limitations of changing the buffering flag after a handle is opened and provides code examples for both functions.

From the article

A customer was copying a file with Copy­File , but they wanted the file handles to be opened as FILE_ FLAG_ NO_ BUFFERING .

We saw some time ago that you can use the progress callback to Copy­File­Ex or Copy­File2 to flush the output handle . Maybe we can use the progress callback to open the handle as unbuffered?

Nope, that doesn’t work because the progress callback gives you the already-opened handle. You can’t change its buffering flag after the fact.


Share this resource


Discovered 2026-08-12 Source The Old New Thing Archive 2026-08 →