本文设备环境:Mac Mono
using System;
using System.Collections.Generic;
using System.Text;
namespace HelloWorld
{
class MainClass
{
public static void Main (string[] args)
{
//默认的路径为bin/Debug
string file = "../../test.txt";
Console.WriteLine("hhh");
string[] data1 = new string[2];
//write file
data1 [0] = "第一条信息";
data1 [1] = "第二条信息";
System.IO.File.WriteAllLines (file, data1);
//read file
if (System.IO.File.Exists (file))
{
Console.WriteLine("sss");
string[] data = new string[2];
data = System.IO.File.ReadAllLines (file);
Console.WriteLine (data [0]);
Console.WriteLine (data [1]);
Console.ReadKey ();
}
}
}
}