Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4519600
  • 博文数量: 356
  • 博客积分: 10458
  • 博客等级: 上将
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-24 14:59
文章分类

全部博文(356)

文章存档

2020年(17)

2019年(9)

2018年(26)

2017年(5)

2016年(11)

2015年(20)

2014年(2)

2013年(17)

2012年(15)

2011年(4)

2010年(7)

2009年(14)

2008年(209)

分类: C/C++

2008-04-16 13:42:32

CStdioFile继承自CFile.

参数内容:

第一个参数为路径+文件名,最后一个为错误出现的结构.

现在解释下第二个参数

CFile::modeCreate   Directs the constructor to create a new file. If the file exists already, it is truncated to 0 length.

指定构造器创建一个新的文件,如果文件已经存在,则内容截0.

CFile::modeNoTruncate   Combine this value with modeCreate. If the file being created already exists, it is not truncated to 0 length. Thus the file is guaranteed to open, either as a newly created file or as an existing file. This might be useful, for example, when opening a settings file that may or may not exist already. This option applies to CStdioFile as well.

modeNoTruncate

假如你不用这个参数的话,用modeCreate模式创建和打开一个文件,假如这个文件已经存在,则会清空这个已经存在的文件,加上modeNoTruncate的话,就不会清空这个文件了

CFile::modeRead   Opens the file for reading only.

只是以读取方式打开

CFile::modeReadWrite   Opens the file for reading and writing.

读与写同时

CFile::modeWrite   Opens the file for writing only.
只写

CFile::modeNoInherit   Prevents the file from being inherited by child processes.

阻止这个文件被子进程继承

CFile::shareDenyNone   Opens the file without denying other processes read or write access to the file. Create fails if the file has been opened in compatibility mode by any other process.

打开这个文件同时允许其它进程读写这个文件。如果文件被其它进程以incompatibility模式打开,这是create操作会失败。

CFile::shareDenyRead   Opens the file and denies other processes read access to the file. Create fails if the file has been opened in compatibility mode or for read access by any other process.

打开文件拒绝其它任何进程读这个文件。如果文件被其它进程用compatibility模式或者是读方式打开,create操作失败。

CFile::shareDenyWrite   Opens the file and denies other processes write access to the file. Create fails if the file has been opened in compatibility mode or for write access by any other process.

打开文件拒绝其它任何进程写这个文件。如果文件被其它进程用compatibility模式或者是写方式打开,create操作失败。

CFile::shareExclusive   Opens the file with exclusive mode, denying other processes both read and write access to the file. Construction fails if the file has been opened in any other mode for read or write access, even by the current process.

 以独占方式打开这个文件,不允许其它进程读写这个文件。

CFile::shareCompat   This flag is not available in 32 bit MFC. This flag maps to CFile::shareExclusive when used in CFile::Open.

这个标志在32位的MFC中无效。

CFile::typeText   Sets text mode with special processing for carriage return–linefeed pairs (used in derived classes only).

CFile::typeText   设置成对回车换行对有特殊处理的文本模式(仅用在派生类中)
CFile::typeBinary   设置二进制模式(仅用在派生类中)

 

CStdioFile::ReadString

virtual LPTSTR ReadString( LPTSTR lpsz, UINT nMax );
throw( CFileException );

BOOL ReadString(CString& rString);
throw( CFileException );

Return Value

A pointer to the buffer containing the text data. NULL if end-of-file was reached without reading any data; or if boolean, FALSE if end-of-file was reached without reading any data.

阅读(8022) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~