HistoryReorcd.cpp
上传用户:flyanjing
上传日期:2015-10-09
资源大小:649k
文件大小:2k
- // HistoryReorcd.cpp: implementation of the CHistoryReorcd class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "ShuangSeQiu.h"
- #include "HistoryReorcd.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CHistoryReorcd::CHistoryReorcd()
- {
- }
- CHistoryReorcd::~CHistoryReorcd()
- {
- }
- //返回文件当前行的内容
- CString CHistoryReorcd::GetLineActionFile(CString filename, int line)
- {
- CString str ;
- CStdioFile myfile;
- if(!myfile.Open(filename,CFile::modeRead))
- {
- myfile.Open(filename,CFile::modeWrite|CFile::modeCreate);
- }
-
- int curline =1;
-
- while(curline <= line){
- myfile.ReadString(str);
- curline++;
- }
- myfile.Close();
- return str;
- }
- //返回文件行数
- int CHistoryReorcd::GetFileLine(CString filename)
- {
- int line =0;
- CStdioFile myfile;
- if(!myfile.Open(filename,CFile::modeReadWrite))
- myfile.Open(filename,CFile::modeWrite|CFile::modeCreate);
- CString str ;
- myfile.ReadString(str);
-
- while(str.GetLength() >=10 ){
- myfile.ReadString(str);
- line++;
- }
- myfile.Close();
- return line;
- }
- CString CHistoryReorcd::GetCurPath()
- {
- TCHAR cPath[_MAX_PATH];
- GetCurrentDirectory(MAX_PATH, cPath);
- CString strPath = cPath;
- strPath.TrimRight("\");
- return strPath;
- }