File類 對檔案的操作

2021-09-26 11:39:05 字數 807 閱讀 1048

void start()

;//writealltext寫入檔案,將所有的字串追加到文字中,不會進行另起一行

// file.writealltext(path,text1);

//writealllines,將所有的字串追加到文字中,第二個引數為陣列,會根據數值中的每乙個值,另起一行進行寫入

file.writealllines(path,text2);

表示新的一行

//讀取文字,把所有的文字儲存在乙個字串裡

string s = file.readalltext(path);

debug.log(s);

//讀取文字,儲存到字串陣列裡,通過索引得到每一行的資料

string s1 = file.readalllines(path,encoding.utf8);

foreach (var item in s1)

}string path2= @"f:\unityprojects_5.6.4\csharpstudy\002.txt";

string text3 = "判斷是否存在,不存在就建立,存在就重新寫入內容";

if (!file.exists(path2))

else

;file.writealllines(path2,text4);

}string path3 = @"f:\unityprojects_5.6.4\csharpstudy\003.txt";

if (!file.exists(path3))

else

}

對檔案file的操作

對於檔案的知識了解的很少,工作中對於這部分用的還是比較多的,而且用的還是比較深。自己應該好好學習學習這方面的知識。讀取資料 public static string readdate system.out.print sb.tostring file sb.tostring catch fileno...

Python對檔案file的操作

file 操作 my file open file.txt w 在當前目錄中建立檔名為 file.txt 的檔案 my file.write something 向檔案中寫入資料 my file.close 關閉檔案 my file open filename r 唯讀方式開啟 my file.re...

利用FILE結構對檔案進行操作

利用file結構對檔案進行操作 輸入若干個學生的資料 包括學號 姓名和成績 將資料存放在student.txt檔案中 從student.txt檔案中讀取所有資料並顯示出來 include include include struct student void main file write,read...