C 檔案類的操作 刪除

2022-05-06 17:15:10 字數 538 閱讀 7388

//

刪除資料夾

1這是最簡單的方法

directoryinfo di = new directoryinfo(string

path);

di.delete(

true

); 注:path是你要刪除的非空目錄;

true

:你要刪除裡面所有的檔案,包括資料夾和子資料夾

2///

///刪除非空資料夾

/// ///

要刪除的資料夾目錄

void deletedirectory(string

path)

dir.delete(

true

); }

} //

刪除檔案

1.遞迴方法:

private

staticv oid deletedirectory(file tmpfile)

if(tmpfile.isdirectory())   }}

}

C 檔案操作類

提供用於建立 複製 刪除 移動和開啟檔案的靜態方法,並協助建立filestream物件。操作物件 檔案。這兩個主要用於操作文字檔案。建立乙個textreader物件,用於以規定編碼讀取字元。對於大的文字檔案,file.alllinetext的操作需要一次性讀取,不安全。filestream大檔案讀取...

C 檔案操作類

using system using system.collections.generic using system.text using system.data using system.reflection using system.collections using system.data.c...

c 檔案操作類

檔案操作類 class filehelper 屬性 檔案路徑 string filepath public string filepath set 得到檔案的完全名字 public string fullfilename string path 寫檔案 public void writefile s...