c 獲取桌面路徑及檔案路徑字串處理

2021-10-19 21:10:59 字數 2117 閱讀 3063

environment.getfolderpath(environment.specialfolder.desktop)
string filepath = @"e:\randy0528\中文目錄\justtest.rar";

response.write("檔案路徑:"+filepath);

response.write("

更改路徑字串的副檔名。

");response.write(system.io.path.changeextension(filepath, "txt"));

response.write("

返回指定路徑字串的目錄資訊。。

");response.write(system.io.path.getdirectoryname(filepath));

response.write("

返回指定的路徑字串的副檔名。

");response.write(system.io.path.getextension(filepath));

response.write("

返回指定路徑字串的檔名和副檔名。

");response.write(system.io.path.getfilename(filepath));

response.write("

返回不具有副檔名的指定路徑字串的檔名。

");response.write(system.io.path.getfilenamewithoutextension(filepath));

response.write("

獲取指定路徑的根目錄資訊。

");response.write(system.io.path.getpathroot(filepath));

response.write("

返回隨機資料夾名或檔名。

");response.write(system.io.path.getrandomfilename());

response.write("

建立磁碟上唯一命名的零位元組的臨時檔案並返回該檔案的完整路徑。

");response.write(system.io.path.gettempfilename());

response.write("

返回當前系統的臨時資料夾的路徑。

");response.write(system.io.path.gettemppath());

response.write("

確定路徑是否包括副檔名。

");response.write(system.io.path.ha***tension(filepath));

response.write("

獲取乙個值,該值指示指定的路徑字串是包含絕對路徑資訊還是包含相對路徑資訊。

");response.write(system.io.path.ispathrooted(filepath));

執行結果

檔案路徑:e:\randy0528\中文目錄\justtest.rar

更改路徑字串的副檔名。

e:\randy0528\中文目錄\justtest.txt

返回指定路徑字串的目錄資訊。。

e:\randy0528\中文目錄

返回指定的路徑字串的副檔名。

.rar

返回指定路徑字串的檔名和副檔名。

justtest.rar

返回不具有副檔名的指定路徑字串的檔名。

justtest

獲取指定路徑的根目錄資訊。

e:返回隨機資料夾名或檔名。

ct2h5b2h.sed

建立磁碟上唯一命名的零位元組的臨時檔案並返回該檔案的完整路徑。

c:\documents and settings\randy\local settings\temp\tmpad.tmp

返回當前系統的臨時資料夾的路徑。

c:\documents and settings\randy\local settings\temp

確定路徑是否包括副檔名。

true

獲取乙個值,該值指示指定的路徑字串是包含絕對路徑資訊還是包含相對路徑資訊。

true

C 從字串獲取檔案路徑

c 從字串獲取檔案路徑 c 擷取帶路徑的檔案名字,副檔名,等等 的幾種方法 c 對磁碟io操作的時候,經常會用到這些,路徑,檔案,檔案名字,副檔名.之前,經常用切割字串來實現,可是經常會弄錯.尤其是啟始位置,多少個位元組,經常弄暈.下面這種方法貌似比較簡便 string filepath e ran...

C 獲取windows桌面的路徑

winshellapi hresult winapi shgetspecialfolderlocation hwnd hwndowner,int nfolder,lpitemidlist ppidl 函式宣告 hwndowner 指定了 所有者視窗 在呼叫這個函式是可能出現的對話方塊或資訊框.nfo...

c 獲取檔案路徑

一 獲取當前檔案的路徑 1.system.diagnostics.process.getcurrentprocess mainmodule.filename 獲取模組的完整路徑,包括檔名。2.system.environment.currentdirectory 獲取和設定當前目錄 該程序從中啟動的...