1、建立一個文本文件 public class FileClass { public static void Main() { WriteToFile(); } static void WriteToFile() { StreamWriter SW; SW=File.CreateText("c:\MyTextFile.txt"); SW.WriteLine("God is greatest of them all"); SW.WriteLine("This is second line"); SW.Close(); Console.WriteLine("File Created SucacessFully"); } }