檔案筆記
fileinfo 需要通過new建立
directoryinfo 需要通過new建立 可以賦值
file 靜態類不需要建立,直接通過.訪問,可以獲取檔案資訊 可以讀取file.readallbytes file.readalllines file.readalltext 和
寫入file.writeallbytes file.writealllines file.writealltext
directory 靜態類不需要建立,直接通過.訪問,可以獲取資料夾資訊 可以刪除,判斷是否存在
filestream 通過new 進行建立檔案流 可以進行讀取 和 寫入 一般用於讀取和寫入二進位制的資訊,一般讀取和寫入還是會使用streamreader 和streamwriter
streamreader 通過new 建立讀入流 通過.readline 讀取一行字串 通過.readtoend 讀取到文字的末尾
streamwriter 通過new建立寫入流 直接通過.write 進行寫入字串 通過.writeline 寫入乙個字串並換行
C 檔案和資料夾
獲取啟動了應用程式的可執行檔案的路徑,不包括可執行檔案的名稱。返回上一級路徑 是你返回的資料夾級數 string parentpath di.fullname 判斷檔案是否存在 if system.io.file.exists parentpath directory.exists path pat...
C 資料夾和檔案操作
file.exist string path 檔案讀寫 filestream fs new filestream filename,filemode.create binarywriter bw new binarywriter fs bw.write ok bw.flush bw.close fs...
刪除檔案和資料夾
一 刪除檔案 使用 del 命令,可以檢視幫助資訊 del p f s q a attributes names erase p f s q a attributes names names 指定乙個或數個檔案或目錄列表。萬用字元可被用來 刪除多個檔案。如果指定了乙個目錄,目錄中的所 有檔案都會被刪...