Data is written to a file on a network share even though the WriteFile function returns a value of 0 for the lpNumberOfBytesWritten parameter when you run a custom application in Windows Vista or Windows Server 2003 SP1 or a later version
Consider the following scenario. You create a custom application on a computer that is running Windows Vista or Microsoft Windows Server 2003 with Service Pack (SP1) or a later version. The custom application opens a file on a network share for write access. Additionally, the custom application uses the WriteFile function to write data to the file. When you run the custom application, you experience the following symptoms:
- The WriteFile function returns an error message.
- The WriteFile function returns a value of 0 (zero) for the lpNumberOfBytesWritten parameter.
You expect that the write operation failed and that no data is written to the file. However, you find that some data is successfully written to the file.
The following is an example of a scenario in which you experience this behavior.
- The custom application opens a file for an unbuffered write operation. The WriteFile function extends the file.
Note: In certain cases, the write operation may be unbuffered even though the application does not specifically set the FILE_FLAG_NO_BUFFERING flag when the application opens the file. For example, if you open the file for write-only access instead of for read and write access, write operations to the file are unbuffered.
- Part of the write operation fails because the disk is full. However, some disk space is freed on the server. Later parts of the write operation are successfully completed.
In this scenario, the following results occur:
- The file contains blank spaces.
- The WriteFile function returns a “STATUS_DISK_FULL” error message.
- The value of the lpNumberOfBytesWritten parameter is set to 0 (zero).
For more information on this issue, including potential causes, workarounds, and resolutions, see: Microsoft KB Article KB935788.

Start
About
FAQ
Blogroll
Shop
Tips and Tricks
Windows Updates
Hotfixes
Keyboard Shortcuts
Vista's Services
Vista's Commands
Product Reviews
Glossary
Videos
Web Links

Comments
There are no comments yet...Come on, share your thoughts!
Leave a Comment