C 檔案讀取

2021-08-18 02:54:11 字數 1095 閱讀 9154

建議從結尾開始看可能不會迷糊,哈哈^_^,剛開始寫部落格,多多指教!嘿嘿

1、在cfolderopt類裡面定義乙個判斷檔案或目錄的成員函式

//判斷檔案或目錄是否存在

//bisdircheck=true 表示為目錄

//bisdircheck=false 表示為檔案

bool cfolderopt::isfileexist(lpctstr lpszfilename, bool bisdircheck)

else

return false;

2、加密檔案的解析

//從加密的檔案中讀出 文字檔案的資訊. 將文字檔案中一行一行地儲存在csaline中.

//而檔案本身不進行解密

bool cdataopt::hstextdecrypt(cstring strpath,cstringarray &csaline)

if ( file.getlength() < 112 )

file.seektobegin();

dword dw = 'jiami';    //此處為加密格式

file.read(&dw,5);

if  ( dw != 'jiami')

file.read(&dw,4);

if  ( dw != 'text')

int ilen;

//跳過時間

file.read(&ilen,5);//寫入占用長度

file.seek(ilen,cfile::current);

//跳過保留的100位

file.seek(96,cfile::current);

int itotal;

if ( file.read( &itotal,4 ) < 4 ) return false;

if ( itotal < 1 )//具體的儲存內容為空

char *name = null;

int i,j;

char uc;

for( i=0;i 0 )

for ( j=0;j3、// 開始加密檔案的讀取

bool cdataopt::beginreaddata(lpctstr strparamspath)

C 讀取檔案

using system using system.collections.generic using system.componentmodel using system.data using system.drawing using system.text using system.window...

c 讀取檔案

用c 讀取檔案內容中文是亂碼的解決方法 方法1 streamreader din new streamreader c 1.txt system.text.encoding.getencoding gb2312 string html while din.peek 1 din.close 方法2 s...

C 檔案讀取

一.fileinfo類,檢視檔案屬性,建立檔案,移動檔案,重新命名檔案等資訊。directoryinfo類,用來獲取資料夾的資訊。二.file讀寫檔案,file.readalllines 讀取所有行string陣列 file.readalltext 讀取整個檔案string file.readall...