在追加模式下创建文件 [英] create Files in appending mode
本文介绍了在追加模式下创建文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在追加模式下创建文件.我需要重用同一文件
只要应用程序正常运行,请帮我找到它.
谢谢
Mithun Nair
Hi,
How can I create Files in appending mode. I need to reuse the same file
whenever the application works.Help me to find it.
Thanks
Mithun Nair
推荐答案
使用CFile
类并使用标志CFile::modeNoTruncate
.
在这里查看更多信息:
http://msdn.microsoft.com/en-us/library/cz0a83sb%28v = vs.80%29.aspx [ ^ ]
祝你好运!
Use theCFile
class and use the flagCFile::modeNoTruncate
.
Have a look here for more info:
http://msdn.microsoft.com/en-us/library/cz0a83sb%28v=vs.80%29.aspx[^]
Good luck!
来自标准C ++库的文件流也是一种选择.
它们不需要 MFC (需要CFile
),并且它们不是特定于操作系统的(CreateFile
和SetFilePointerEx
是Windows特定的API).
您可以使用 std :: ofstream [ std :: ofstream :: open [
The file streams from The Standard C++ Library are also an option.
They don''t require MFC (CFile
does) and they are not OS specific (CreateFile
andSetFilePointerEx
are Windows specific APIs).
You can use std::ofstream[^].
See the documentation for std::ofstream::open[^] and. You can use something like:
std::ofstream myfilebin, myfiletxt;
// For binary files
myfilebin.open ("example.bin", std::ios::out | std::ios::app | std::ios::binary);
// For text files
myfiletxt.open ("example.txt", std::ios::out | std::ios::app);
有关其他详细信息,请参考此 [
For additional details refer to this[^] article.
您还可以使用CreateFile [ SetFilePointerEx [ ^ ] Windows API函数.
问候
Espen Harlinn
You can also use the CreateFile[^] and the SetFilePointerEx[^] Windows API functions.
Regards
Espen Harlinn
这篇关于在追加模式下创建文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文