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"); } }