posts - 124,  comments - 29,  trackbacks - 0
public class File
{
    string fileName;
    public File(string fileName)
   {
       this.fileName=fileName;
   }

   public string ReadFile() 
  {
     try
      {
         StreamReader sr=new StreamReader(fileName,Encoding.Default);
         string result=sr.ReadToEnd();
         sr.Close();
         return result;
       }
       catch(Exception e){MessageBox.Show(e.Message);}
       return null; 
  }

   public void WriteFile(string str)
  {
     try
     {
        StreamWriter sw=new StreamWriter(fileName,false,Encoding.Default);
        sw.Write(str);
        sw.Close();
      }
      catch(Exception e){MessageBox.Show(e.Message,"保存文件出错!");} 
  }
}

posted on 2008-09-05 14:26 天书 阅读(515) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2008年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(5)

随笔档案

文章分类

文章档案

好友的Bolg

搜索

  •  

最新评论

阅读排行榜

评论排行榜