日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

VC++ 删除当前读取行 代码

發(fā)布時間:2024/4/15 c/c++ 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VC++ 删除当前读取行 代码 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

操作Text,要刪除當前讀取的行。(VC 文件操作DEMO)

我想到兩種方法:?? ? ? ??

1.生成臨時文件 讀一行 寫進去 跳過要刪除的行

2.全部讀入內(nèi)存 刪除 然后寫回txt文件

?第一種方法上代碼:

View Code 1 void CPoint7Dlg::OnBnClickedButton5() 2 { 3 4 CString strPathName; 5 GetModuleFileName(NULL,strPathName.GetBuffer(256),256); 6 strPathName.ReleaseBuffer(256); 7 int nPos = strPathName.ReverseFind('\\'); 8 strPathName = strPathName.Left(nPos +1); 9 10 CStdioFile file; 11 CString str; 12 CString firstStr; 13 CString strFull; 14 str.Format(strPathName+"Log\\1.txt",g_BasePath); 15 if (file.Open(_T(str),CFile::modeRead | CFile::typeText)) 16 { 17 file.SeekToBegin(); 18 int i=1; 19 while(file.ReadString(str)) 20 { 21 if(i>1) 22 { 23 strFull+=str+"\n"; 24 } 25 i++; 26 } 27 file.Close(); 28 MessageBox(strFull); 29 } 30 else 31 { 32 MessageBox(_T("data1.txt文件打開失敗")); 33 } 34 35 strPathName; 36 GetModuleFileName(NULL,strPathName.GetBuffer(256),256); 37 strPathName.ReleaseBuffer(256); 38 nPos = strPathName.ReverseFind('\\'); 39 strPathName = strPathName.Left(nPos +1); 40 41 42 str.Format(strPathName+"Log\\1.txt",g_BasePath); 43 44 if (!file.Open(_T(str),CFile::modeCreate | CFile::modeWrite | CFile::typeText)) 45 { 46 MessageBox(_T("未打開文件")); 47 } 48 else 49 { 50 file.WriteString(strFull); 51 file.Close(); 52 } 53 }

轉載于:https://www.cnblogs.com/jak-black/archive/2012/11/23/2783953.html

總結

以上是生活随笔為你收集整理的VC++ 删除当前读取行 代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。