• 根据内容对文件进行比较


    实现效果:

      

    知识运用:

      StreamReader类用来实现TextReader抽象类   使其以一种特定的编码从字节流中读取字符

      其ReadToEnd方法用来从当前流的当前位置到末尾读取流  

      public override string ReadToEnd()      //如果当前位置位于流的尾端 则返回空字符串 ("")

    实现代码:

            private void button3_Click(object sender, EventArgs e)
            {
                StreamReader sr1 = new StreamReader(textBox1.Text);
                StreamReader st2 = new StreamReader(textBox2.Text);
                if (object.Equals(sr1.ReadToEnd(), st2.ReadToEnd()))
                {
                    MessageBox.Show("两个文件相等");
                }
                else { MessageBox.Show("两个文件不相等"); }
            }
    
  • 相关阅读:
    哈佛大学官网图标下拉变小代码
    9.23 基础知识
    选项卡效果
    滑动效果
    进度条的制作
    图片轮播
    子菜单下拉
    DIV做下拉列表
    日期时间选择
    电池的基本知识
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10226607.html
Copyright © 2020-2023  润新知