VS通過檔案路徑名查詢到當前資料夾和當前檔名

2021-07-05 22:16:48 字數 823 閱讀 8677

程式開發中,有時候找到乙個檔案路徑,需要找到這個檔案所在的資料夾和該檔案的名稱。

具體實現**:

cstring str = _t("c:\\mytest\\test.txt");

int n = str.reversefind(_t('\\'));

cstring sfolderpath = str.left(n);

cstring sfilenametype = str.right(str.getlength() - n - 1 );

int m = sfilenametype.reversefind(_t('.'));

cstring sfilename = sfilenametype.left(m);

cstring stemp = _t("");

stemp = _t("完整檔案路徑名稱:") + str;

str = stemp + _t('\r');

stemp = _t("資料夾路徑:") + sfolderpath;

str = str + stemp + _t('\r');

stemp = _t("檔名稱:") + sfilenametype;

str = str + stemp + _t('\r');

stemp = _t("檔名:") + sfilename;

str = str + stemp + _t('\r');

messagebox(str);

效果

php 獲取當前目錄和當前資料夾

php獲取路徑或目錄實現 魔術變數,獲取當前檔案的絕對路徑 echo file file echo php eol.php eol 魔術變數,獲取當前指令碼的目錄 echo dir dir echo php eol.php eol dirname返回路徑的目錄部分,dirname file 相當於 ...

獲取當前檔案路徑

getcurrentdirectory只是返回當前程序的當前目錄,而並不是程序的映象檔案 exe 所在的目錄 getcurrentdirectory 適用於xp等系統,在wince上不能使用 getmodulefilename 適用於wince2.0以後 使用方法 下面的一段 主要是獲得當前程式的執...

獲取當前檔案路徑。

之前搞模組載入,苦於無法獲取當前檔案路徑,檔名 後來沒通過獲取當前檔案路徑,檔名,給搞定了。結果今天把這個問題也解決了,做個記錄 file zhus err.js varcursrc newfunction catch e console.log cursrc zhus err 以上編碼,只適用於f...