VC獲取從檔案路徑中返回檔名和副檔名兩個引數

2021-06-07 07:52:12 字數 566 閱讀 1444

呼叫方法:

cstring a,b,c;

a="c:\\kele8\\shootman2\\vision\\123.exe";

b=this->getfiletitlefromfilename(a,c);

afxmessagebox(b);

afxmessagebox(c);

還有一種方法:

cstring cprintimage::getfiletitlefromfilename(cstring filename, bool ext)    

return filetitle;    

}  呼叫方法:

cstring a,b,c;

a="c:\\kele8\\shootman2\\vision\\123.exe";

b=this->getfiletitlefromfilename(a,true);

c=this->getfiletitlefromfilename(a,false);

afxmessagebox(b);   彈出123.exe

afxmessagebox(c);   彈出123

Linux C 從指定路徑中獲取檔名

linux 或者 android 下可以通過 strrchr 函式從指定路徑中獲取檔名,這個函式的作用是 查詢字串中最後乙個出現的指定字元,它還有乙個對應函式 strchr 可用於 查詢字串第乙個出現的指定字元。使用這兩個函式前,需要 include 例 include include includ...

獲取檔名和檔案路徑

1.問題描述 比如已經知道檔案的路徑是 c dir0 dir1 readme.txt 除了用split 的方式獲取檔名和路徑,有沒有什麼更高效的方式 2.解決辦法 os.path.dirname 路徑 os.path.basename 檔名 import os file path d work te...

QT中獲取檔案路徑和檔名

我發現各種教程都有乙個毛病,就是愛把資料寫死在 裡,比如建個資料庫 sqlite3.connect test.db 插入個資料insert into user values 12 這些 怎麼用,怎麼用,怎麼用!看著這種 就氣不打一處來,換個資料怎麼辦,在 裡改?假設我現在想每開啟乙個檔案,就對應建立...