91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 53KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-20
  • 語言: C#
  • 標簽: txt??C#??去重??

資源簡介

winform中,瀏覽一個文件,將txt文件中的重復記錄去掉。 首先將txt文檔中的記錄,映射到DataTable中,然后進行處理。

資源截圖

代碼片段和文件信息

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;
using?System.Data.SqlClient;
using?System.Data.OleDb;
using?System.Collections;

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

????????#region?瀏覽按鈕
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????OpenFileDialog?file?=?new?OpenFileDialog();
????????????file.InitialDirectory?=?“F:\\test\\“;
????????????file.AddExtension?=?true;
????????????file.FileName?=?“*.txt“;
????????????file.ShowDialog();
????????????this.filesName.Text?=?file.FileName;
????????}
????????#endregion?瀏覽按鈕

????????#region?去掉重復按鈕
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????this.richTextBox1.Text?=?““;
????????????string?filename?=?this.filesName.Text;
????????????if?(filename?!=?““)
????????????{
????????????????//路徑
????????????????string?path?=?“F:\\test\\“;
????????????????//文件名稱
????????????????string?file?=?filename.Substring(filename.Length?-?21);

????????????????//將txt文檔映射到DataTable中
????????????????DataTable?table?=?TxtToDataTable(path?file);
????????????????//去掉重復的行,【當第一個字段相同的兩條記錄,刪除時間較早的那條記錄】
????????????????//例如:
????????????????//“6210810180000778752““1292107695““2100077875““1630002100077875““2013/12/04““13:48:54“
????????????????//“6210810180000778752““3567307695““2100077875““1630002100077875““2013/12/04““15:30:03“
????????????????//去掉第一條記錄,保留第二條
????????????????//.........TODO
????????????????//DataTable?dt_new?=?table.DefaultView.ToTable(true?“F1“);
????????????????//int?count?=?dt_new.Rows.Count;
?????????????????DataRow[]?dataRows?=?table.Select(““);
?????????????????Hashtable?hash?=?new?Hashtable();
?????????????????int?chongfuCount?=?0;
?????????????????foreach?(DataRow?row?in?dataRows)//去重開始
?????????????????{
?????????????????????string?icNo?=?row[0].ToString();
?????????????????????if?(hash.ContainsKey(icNo))
?????????????????????{
?????????????????????????chongfuCount++;
?????????????????????????DataRow?row1?=(DataRow)?hash[icNo];
?????????????????????????this.richTextBox1.AppendText(row1[0].ToString()?+?““?+?row1[1].ToString()?+?““?+?row1[2].ToString()?+?““?+?row1[3].ToString()?+?““?+?row1[4].ToString()?+?““?+?row1[5].ToString());
?????????????????????????this.richTextBox1.AppendText(“\r\n“);
?????????????????????????hash.Remove(icNo);
?????????????????????????hash.Add(icNo?row);
?????????????????????}
?????????????????????else?
?????????????????????{
?????????????????????????hash.Add(icNo?row);
?????????????????????}
?????????????????}//去重結束
?????????????????label3.Text?=?chongfuCount.ToString();

?????????????????//遍歷hashTable,變成DataTable
?????????????????DataTable?quchongTable?=?new?DataTable();

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????12800??2013-12-27?11:21??Txt文檔去掉重復記錄\RemoveTxtChongfu\bin\Debug\RemoveTxtChongfu.exe

?????文件??????28160??2013-12-27?11:21??Txt文檔去掉重復記錄\RemoveTxtChongfu\bin\Debug\RemoveTxtChongfu.pdb

?????文件??????11600??2013-12-27?11:25??Txt文檔去掉重復記錄\RemoveTxtChongfu\bin\Debug\RemoveTxtChongfu.vshost.exe

?????文件????????490??2010-03-17?22:39??Txt文檔去掉重復記錄\RemoveTxtChongfu\bin\Debug\RemoveTxtChongfu.vshost.exe.manifest

?????文件???????6420??2013-12-27?11:12??Txt文檔去掉重復記錄\RemoveTxtChongfu\Form1.cs

?????文件???????6930??2013-12-27?10:32??Txt文檔去掉重復記錄\RemoveTxtChongfu\Form1.Designer.cs

?????文件???????5817??2013-12-27?10:32??Txt文檔去掉重復記錄\RemoveTxtChongfu\Form1.resx

?????文件??????39883??2013-12-27?08:59??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

?????文件???????6332??2013-12-27?11:21??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

?????文件????????316??2013-12-27?10:32??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug\GenerateResource.read.1.tlog

?????文件????????766??2013-12-27?10:32??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug\GenerateResource.write.1.tlog

?????文件???????1084??2013-12-27?11:25??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug\RemoveTxtChongfu.csproj.FileListAbsolute.txt

?????文件??????12800??2013-12-27?11:21??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug\RemoveTxtChongfu.exe

?????文件????????180??2013-12-27?10:32??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug\RemoveTxtChongfu.Form1.resources

?????文件??????28160??2013-12-27?11:21??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug\RemoveTxtChongfu.pdb

?????文件????????180??2013-12-27?09:02??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug\RemoveTxtChongfu.Properties.Resources.resources

?????文件????????497??2013-12-27?08:59??Txt文檔去掉重復記錄\RemoveTxtChongfu\Program.cs

?????文件???????1364??2013-12-27?08:59??Txt文檔去掉重復記錄\RemoveTxtChongfu\Properties\AssemblyInfo.cs

?????文件???????2882??2013-12-27?08:59??Txt文檔去掉重復記錄\RemoveTxtChongfu\Properties\Resources.Designer.cs

?????文件???????5612??2013-12-27?08:59??Txt文檔去掉重復記錄\RemoveTxtChongfu\Properties\Resources.resx

?????文件???????1101??2013-12-27?08:59??Txt文檔去掉重復記錄\RemoveTxtChongfu\Properties\Settings.Designer.cs

?????文件????????249??2013-12-27?08:59??Txt文檔去掉重復記錄\RemoveTxtChongfu\Properties\Settings.settings

?????文件???????3691??2013-12-27?09:02??Txt文檔去掉重復記錄\RemoveTxtChongfu\RemoveTxtChongfu.csproj

?????文件???????1204??2013-12-27?11:25??Txt文檔去掉重復記錄\Txt文檔去掉重復記錄.sln

????..A..H.?????19456??2013-12-27?11:26??Txt文檔去掉重復記錄\Txt文檔去掉重復記錄.suo

?????目錄??????????0??2013-12-27?08:59??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug\TempPE

?????目錄??????????0??2013-12-27?11:21??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86\Debug

?????目錄??????????0??2013-12-27?09:02??Txt文檔去掉重復記錄\RemoveTxtChongfu\bin\Debug

?????目錄??????????0??2013-12-27?08:59??Txt文檔去掉重復記錄\RemoveTxtChongfu\obj\x86

?????目錄??????????0??2013-12-27?08:59??Txt文檔去掉重復記錄\RemoveTxtChongfu\bin

............此處省略7個文件信息

評論

共有 條評論