記事本檔案的讀寫
阿新 • • 發佈:2018-12-17
#region 寫入記事本檔案,並且儲存到本地,實現資料的讀寫 //public void WriteFileByLine(string file_path, string file_name, string str_info) //{ // StreamWriter sw; // if (!File.Exists(file_path + "//" + file_name)) // { // sw = File.CreateText(file_path + "//" + file_name);//建立一個用於寫入 UTF-8 編碼的文字 // Debug.Log("檔案建立成功!" + Application.persistentDataPath); // } // else // { // sw = File.AppendText(file_path + "//" + file_name);//開啟現有 UTF-8 編碼文字檔案以進行讀取 // } // sw.WriteLine(str_info);//以行為單位寫入字串 // sw.Close(); // sw.Dispose();//檔案流釋放 //} //void Start() //{ // WriteFileByLine(Application.persistentDataPath, "my_newfile.txt", "儲存資訊"); //} #endregion