FileStream file = new FileStream("user.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamReader sd = new StreamReader(file);
string[] user = sd.ReadLine().Split('=');
MessageBox.Show(user[1]);
sd.Close();
file.Close();文件内容是Application=true 想把true修改成false,有什么方法吗?

解决方案 »

  1.   

    WriteAllText 可以,还有其他方法吗?
      

  2.   

    FileStream file = new FileStream("user.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
                StreamReader sd = new StreamReader(file);
                string str = sd.ReadToEnd();
                str = str.Replace("Application=true", "Application=false");
                
                sd.Close();
                file.Close();            FileStream fs = File.Create("user.txt");
                StreamWriter sw = new StreamWriter(fs);
                sw.Write(str);
                sw.Flush();
                sw.Close();
                fs.Close();