导入一个txt文本,快速过滤重复行
HashSet<string> strlist = new HashSet<string>();
if(openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK){
//
string filename = openFileDialog1.FileName;
int repcnt=0;
string[] lines = System.IO.File.ReadAllLines(filename,System.Text.Encoding.Default);
for(int i=0;i<lines.Length;i++){
if(lines[i]!=""){
if( !strlist.Add(lines[i])){
repcnt++;
}
}
}
if(repcnt>0){
SetLog("过滤重复 " + repcnt);
}
SetLog("导入数量 " + strlist.Count);
}