CStdioFile Class
2015-12-06 23:37
134 查看
CStdioFile : CFile : CObject
A CStdioFile object represents a C run-time stream file as opened by the run-time functionfopen. Stream files are buffered and can be opened in either text mode (the default) or binary mode.Text mode provides special processing for carriage return–linefeed pairs. When you write a newline character (0x0A) to a text-modeCStdioFile object, the byte pair (0x0D, 0x0A) is sent to the file. When you read, the byte pair (0x0A, 0x0D)
is translated to a single 0x0A byte.
The CFile functions
Duplicate, LockRange, and
UnlockRange are not supported for CStdioFile.
If you call these functions on a CStdioFile, you will get a
CNotSupportedException.
For more information on using CStdioFile, see the articleFiles in MFC inVisual C++ Programmer’s Guide andFile Handling in the
Run-Time Library Reference.
#include <afx.h>
CStdioFile Class Members
Data Membersm_pStream | Contains a pointer to an open file. |
CStdioFile | Constructs a CStdioFile object from a path or file pointer. |
ReadString | Reads a single line of text. |
WriteString | Writes a single line of text. |
CString strPath = "F:\\VBA\\*.*"; CString strFileName; CStringArray strResult; strResult.RemoveAll(); //文件列表清空 CFileFind finder; CStdioFile OutFile; BOOL bWorking = finder.FindFile(strPath); while (bWorking) { bWorking = finder.FindNextFile(); if(finder.IsDirectory()) //若确定找到的文件是否是一个目录,结束本次循环。 continue; strFileName = finder.GetFileName(); //cout << (LPCTSTR)strFileName << endl; strResult.Add(strFileName); } finder.Close(); int iCount = strResult.GetSize(); if(iCount > 0) { //OutFile.Open("F:\\VBA\\Names.xls",CFile::modeCreate | CFile::modeWrite); OutFile.Open("F:\\VBA\\Names.txt",CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite); int i; for(i = 0;i < iCount;i++) { cout << (LPCTSTR)strResult.GetAt(i) << "\n"; OutFile.WriteString(strResult.GetAt(i) + "\n"); } cout << "最大索引是:" << strResult.GetUpperBound() << "\n"; cout << "元素总数是:" << strResult.GetSize() << "\n"; OutFile.Close(); system("pause"); } else { ; }
相关文章推荐
- 利用 RecyclerView 实现垂直交错的网格
- HDU 1207 汉诺塔II DP
- 怎样学习 C++ STL?
- React的Transaction浅析
- 20135210程涵——信息安全系统设计基础第十三周学习总结
- WebSocket的过程与理解
- Java String StringBuffer StringBuilder
- 在win10+Linux Ubuntu双系统下安装win xp三系统的痛苦经历
- 【Unix/Linux编程实践】文件系统:编写pwd
- hdu 5592 线段树 + 二分
- LeetCode 231判断2的幂
- KMP算法(下篇)
- 【郝斌数据结构自学笔记】53-56_一个函数为什么可以自己调用自己_递归必须满足三个条件_循环和递归的比较
- 一个Demo理解工厂设计模式
- js拖拽
- 轻量级mvvm Web开发框架 postby:http://zhutty.cnblogs.com
- HTML5 Canvas入门
- 【数据拾遗(java描述)】--- 哈夫曼树的基本实现
- html5 - 基础格式认识和标签用法(文本元素常用方法)
- 通过转移表练习函数指针的使用