CStdioFile类逐行读写日志记录文件
2016-04-05 21:51
211 查看
写入文件的例子
//创建文件
CStdioFile file;
file.Open("ts.txt",CFile::modeCreate|CFile::modeWrite);
//写入文件
CString str;
str.Format("%s\r\n","hello!I am talkingmute!");(在末尾添加\r\n会导致写出来的文档修改后出现格式错乱,只能写\n)
file.Seek(0,CFile::end);
file.WriteString( str );
//关闭文件
file.Close();
比如:读文件的例子
CString strText = “”;
CString szLine = “”;
//打开文件
CStdioFile file;
file.Open("ts.txt",CFile::modeRead);
//逐行读取字符串
while( file.ReadString( szLine ) )
{
strText += szLine;
}
MessageBox(strText);
//关闭文件
file.Close();
写入文件的例子
//创建文件
CStdioFile file;
file.Open("ts.txt",CFile::modeCreate|CFile::modeWrite);
//写入文件
CString str;
str.Format("%s\r\n","hello!I am talkingmute!");(在末尾添加\r\n会导致写出来的文档修改后出现格式错乱,只能写\n)
file.Seek(0,CFile::end);
file.WriteString( str );
//关闭文件
file.Close();
比如:读文件的例子
CString strText = “”;
CString szLine = “”;
//打开文件
CStdioFile file;
file.Open("ts.txt",CFile::modeRead);
//逐行读取字符串
while( file.ReadString( szLine ) )
{
strText += szLine;
}
MessageBox(strText);
//关闭文件
file.Close();
相关文章推荐
- MySQL Server 日志
- Awstats处理多apache日志
- 建立企业信息化-重头开始
- 用批处理实现读取文本文件并实现超链接代码的输出[原创]_DOS/BAT_脚本之家
- 典型入侵日志分析
- 文本最末列数值乘一个数的批处理实现
- MSSQL 2005 LOG备份webshell的方法
- 实现两个文本同行交替输出的批处理代码
- MS SQL Server数据库清理错误日志的方法
- 对MySQL日志操作的一些基本命令总结
- 简介操作MySQL日志的一些方法
- MySQL的日志基础知识及基本操作学习教程
- MSSQL 2005/2008 日志压缩清理方法小结
- 随日期每天自动变换的文本的js特效
- SQL Server误区30日谈 第19天 Truncate表的操作不会被记录到日志
- 文本、Excel、Access数据导入SQL Server2000的方法
- C#3.0使用EventLog类写Windows事件日志的方法
- C#实现txt定位指定行完整实例
- TXT转HTM、HTML「TXT转网页」的vbs实现代码
- C#处理文本文件TXT实例详解