You cannot call the fwrite function to write to a buffer that is larger than 64 MB in Visual C++ 2005, in Visual C++ .NET 2003, or in Visual C++ .NET 2002

Article translations Article translations
Article ID: 899149 - View products that this article applies to.
Expand all | Collapse all

SYMPTOMS

Consider the following scenario. In Microsoft Visual C++ 2005, in Microsoft Visual C++ .NET 2003, or in Microsoft Visual C++ .NET 2002, you use the fopen function to open a file that is on a network drive. In the function call, you use the wb (write and binary) access type as the mode parameter. If you then call the fwrite function to write to a buffer that is larger than 67,076,095 bytes, the function call fails.

Note 67,076,095 bytes are approximately 64 megabytes (MB).

CAUSE

The problem occurs because of a limitation of the operating system.

WORKAROUND

To work around this problem, use one of the following methods:
  • When you open a file, use the w+b (reading and writing) access type as the mode parameter.
  • Use a smaller buffer. Then, call the fwrite function in a loop until you write the number of bytes that you want to the file.

REFERENCES

For more information about the fopen and fwrite functions, visit the following Microsoft Developer Network (MSDN) Web sites:
fopen, _wfopen
http://msdn2.microsoft.com/en-us/library/yeby3zcb(vs.71).aspx

fwrite
http://msdn2.microsoft.com/en-us/library/h9t88zwz(vs.71).aspx

Properties

Article ID: 899149 - Last Review: November 16, 2007 - Revision: 2.2
APPLIES TO
  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ .NET 2002 Standard Edition
Keywords: 
kbopenfile kbcode kbtshoot kbprb KB899149

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com