十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
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); } }