微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Silverlight独立存储之读写文件

引用 using System.IO; using System.IO.IsolatedStorage; 激发按钮事件 写入 private boid button_Click(object sender,System.Windows.RotedEventArgs e){         if(this.textBox.Text=="" || this.passwordBox.Password==""){                     MessageBox.Show("缺少输入信息");         }         IsolatedStorageFileStrea m isoStore=new IsolatedStorageFileStrea m("myinfo.txt",FileMode.Create,IsolatedStorageFile.GetUserStoreForApplicati on());       StreamWriter wtxt=new StreamWriter(isoStore);       wtxt.WriteLine(this.textBox.Text.Trim());       wtxt.WriteLine(this.passwordBox.Password.Trim());       wtxt.Close();       isoStore.Close();       MessageBox.Show("独立存储吸入myinfo.txt完成!"); } 激发按钮事件  读出 private boid buttonread_Click(object sender,System.Windows.RotedEventArgs e){         this.textblock.Text="";         if(!IsolatedStorageFile.GetUserStoreForApplicati on().FileExists("myinfo.txt")){               MessageBox.Show("没有可用的独立存储文件!");     }       IsolatedStorageFileStrea m isoStore=new IsolatedStorageFileStrea m("myinfo.txt",FileMode.Open,IsolatedStorageFile.GetUserStoreForApplicati on());       StreamReader rtxt=new StreamReader(isoStore);       this.textblock.Text=rtxt.ReadLine();       this.textblock.Text+="\r\n";       this.textblock.Text+=rtxt.ReadLine();       rtxt.Close();       isoStore.Close(); }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐