C 實現遍歷資料夾獲取指定字尾名檔案

2021-09-12 00:23:24 字數 736 閱讀 6093

專案需要,要進行某資料夾下所有shp資料的讀取

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.linq;

using system.text;

using system.windows.forms;

namespace learngdal

private void button3_click(object sender, eventargs e)

}/// /// 獲得目錄下所有檔案或指定檔案型別檔案(包含所有子資料夾)

///

/// 資料夾路徑

/// 副檔名可以多個 例如 .***.wma.rm

C 資料夾字尾名含義

bin 目錄用來存放編譯的結果,bin是二進位制binrary的英文縮寫,因為最初c編譯的程式檔案都是二進位制檔案,它有debug和release兩個版本,分別對應的資料夾為bin debug和bin release,這個資料夾是預設的輸出路徑,我們可以通過 專案屬性 配置屬性 輸出路徑來修改。ob...

獲取檔案字尾名

獲取到filename的字尾 利用lastindexof 從最後面截字尾,找到最後乙個點的索引然後加一,利用substring擷取該索引後的字串 f.getfilename substring f.getfilename lastindexof 1 lastindexof 方法有以下四種形式 pub...

獲取檔案的字尾名

使用api pathfindextension實現獲取給定乙個檔案,直接獲取檔案的字尾名 如 檔名 hsduiew.txt jhdsi.adiwey 路徑 檔名 c hsh shsh tetet.txt 都可以直接獲取到字尾名。pathfindextension函式說明 函式原型 ptstr pat...