读:TextBox1.Text=File.ReadAllText("d:/b.txt",Encoding.Default);
写:File.WriteAllText("d:/a.txt", TextBox1.Text, Encoding.Default);
追加:File.AppendAllText("d:/a.txt", TextBox1.Text, Encoding.Default);
程序集中指定路径:EnsurePathExists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "submit"));
判断路径:
void EnsurePathExists(string path)
{
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
}