vc開啟檔案和儲存檔案

2021-05-25 05:43:16 字數 760 閱讀 6421

開啟檔案

cfiledialog dlg(true,null,null,ofn_hidereadonly|ofn_overwriteprompt,

"all files(*.txt)|*.txt||",afxgetmainwnd());

if ( dlg.domodal()!=idok ) return;

//獲取檔案的絕對路徑

sfilename=dlg.getpathname();

//開啟檔案

cstdiofile out;

out.open(sfilename, cfile::moderead);

cstring text="",line;

//讀取檔案

while(out.readstring(line))

getdlgitem(idc_edit2)->setwindowtext(sfilename);

getdlgitem(idc_edit1)->setwindowtext(text);

out.close();

儲存檔案:

cfiledialog dlg(false,null,null,ofn_hidereadonly|ofn_overwriteprompt,

"all files(*.txt)|*.txt||",afxgetmainwnd());

cstring strpath,strtext="";

char write[10000];

if(dlg.domodal() == idok)

VC 開啟檔案

vs2012 開啟檔案可以使用cfile類中的open函式 本例項的實現只要使用cfile類中的open函式。基本格式如下 virtual bool open lpctstr lpszfilename,uint nopenflags,cfileexception perror null 1.lpsz...

python 開啟和儲存資料檔案

開啟資料檔案 read csv 從檔案,url 檔案型物件中載入帶分隔符資料,預設分隔符為逗號,輸出為字典集 1 需要確定檔案的路徑,格式,資料分隔符,有無列標題,編碼格式,該方式只能適用於開啟資料檔案 ratings pd.read csv user u.data 路徑及檔名 sep t 使用的分...

檔案的開啟(fopen) 讀取和儲存

檔案則分二進位制檔案和文字檔案,二進位制檔案開啟時二進位制符號,文字檔案開啟則是字元 接下來說的是二進位制和文字檔案的讀寫 二進位制檔案 size t fwrite const void ptr,size t size,size t nmemb,file stream 功能 從記憶體讀取資料到檔案中...