• 大小: 43KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: C#
  • 标签: 文本对比  C#  

资源简介

还行,可以用,C#的,本来是自己用的,分不够了,换分,就是一个简单的对比工具,代码没多少,适合初学的

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            label1.Text = ““;
            char[] text1 = new char[textBox1.Text.ToString().Length];
            char[] text2 = new char[textBox2.Text.ToString().Length];
            text1 = textBox1.Text.ToCharArray();
            text2 = textBox2.Text.ToCharArray();
            List textlist1 = new List();
            List textlist2 = new List();

            int n = 0;
            int i = 0;
            int length = textBox1.Text.ToString().Length;

            for (i = 0; i < length; i++)
            {
                if (text1[i] == ‘\n‘)
                {
                    textlist1.Add(textBox1.Text.Substring(n i - n + 1));
                    n = i + 1;
                }
                progressBar1.Value = (30 * (i + 1)) / length;
            }
            textlist1.Add(textBox1.Text.Substring(n i - n));

            n = 0;
            length = textBox2.Text.ToString().Length;
            for (i = 0; i             {
                if (text2[i] == ‘\n‘)
                {
                    textlist2.Add(textBox2.Text.Substring(n i - n + 1));
                    n = i + 1;
                }
                progressBar1.Value = (30 * (i + 1)) / length + 30;
            }
            textlist2.Add(textBox2.Text.Substring(n i - n));
            length = textlist1.Count < textlist2.Count ? textlist1.Count : textlist2.Count;
            for (i = 0; i             {
                if (!textlist1.ElementAt(i).Equals(textlist2.ElementAt(i)))
                {
                    label1.Text += “第“ + i + “行有不相同!\n“;
                }
                progressBar1.Value = (40 * (i + 1)) / length + 60;
            }
            if (textBox1.Text.ToString().Equals(textBox2.Text.ToString()))
                MessageBox.Show(“不用比了,完全一样!“);
            else if (label1.Text != ““)
            {
                MessageBox.Show(“有不同!“);
            }
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    .CA....     10240  2010-07-29 14:06  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

    .CA....     26112  2010-07-29 14:06  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

    .CA....      4594  2010-07-29 14:26  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.rar

    .CA....     14328  2010-07-29 14:07  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

    .CA....       490  2009-06-11 05:14  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

    .CA....      2493  2010-07-29 14:09  WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs

    .CA....      4047  2010-07-29 13:57  WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs

    .CA....      5814  2010-07-29 13:57  WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx

    .CA....      1035  2010-07-29 14:07  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

    .CA....       847  2010-07-29 13:57  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache

    .CA....     10240  2010-07-29 14:06  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe

    .CA....       180  2010-07-29 13:57  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form1.resources

    .CA....     26112  2010-07-29 14:06  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb

    .CA....       180  2010-07-29 12:01  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources

    .CA....       505  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1\Program.cs

    .CA....      1380  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1\Properties\AssemblyInfo.cs

    .CA....      2898  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.Designer.cs

    .CA....      5612  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.resx

    .CA....      1109  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.Designer.cs

    .CA....       249  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.settings

    .CA....      3794  2010-07-29 11:32  WindowsFormsApplication1\WindowsFormsApplication1\WindowsFormsApplication1.csproj

    .CA....       962  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1.sln

    .CA..H.     19456  2010-07-29 14:09  WindowsFormsApplication1\WindowsFormsApplication1.suo

    .C.D...         0  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TempPE

    .C.D...         0  2010-07-29 14:26  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug

    .C.D...         0  2010-07-29 14:06  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug

    .C.D...         0  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1\bin

    .C.D...         0  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1\obj

    .C.D...         0  2010-07-29 11:22  WindowsFormsApplication1\WindowsFormsApplication1\Properties

    .C.D...         0  2010-07-29 14:09  WindowsFormsApplication1\WindowsFormsApplication1

............此处省略4个文件信息

评论

共有 条评论