重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
using System; using System.IO; class predefinedTypes { public static void Main() { // 在当前目录创建一个文件myfile.txt,对该文件具有读写权限 FileStream fsMyfile = new FileStream("myfile.txt" , FileMode.Create , FileAccess.ReadWrite); //写入 StreamWriter swMyfile = new StreamWriter(fsMyfile); string wd=Console.ReadLine(); swMyfile.WriteLine(wd); swMyfile.Flush(); //读出 StreamReader srMyfile= new StreamReader(fsMyfile); srMyfile.BaseStream.Seek(0, SeekOrigin.Begin); string rl=srMyfile.ReadLine(); Console.WriteLine(rl); } }