private void WriteTxt02()//逐行写入
{
string filePath4 = Path.Combine(Application.streamingAssetsPath, "testTXT.txt");
// 要写入的内容
string contentToWrite2 = "Hello, this is a test message.\nThis is a new line.";
// 使用 StreamWriter 写入文件内容
using (StreamWriter writer = new StreamWriter(filePath4))
{
writer.WriteLine(contentToWrite2); // 写入内容
}
}
private void WriteTxt02()//支持逐行写入
{
// 设置文本文件的路径(在 Unity 的 StreamingAssets 文件夹中)
string filePath4 = Path.Combine(Application.streamingAssetsPath, "testTXT.txt");
// 要写入的内容
string contentToWrite2 = "Hello, this is a test message.\nThis is a new line.";
using (StreamWriter writer2 = new StreamWriter(filePath4, true))
{
writer2.WriteLine("This line will be appended.");
}
}