try
{
StreamReader sr = null;
string s;
Hashtable ngHash = new Hashtable();
//NGデータのHashtable作成
try
{
sr = new StreamReader(@"C:\temp\ngdata.txt", Encoding.GetEncoding(932));
while ((s = sr.ReadLine()) != null) { ngHash[s] = true; }
}
finally
{
if (sr != null) sr.Close();
}
//出力データを作成
sr = null;
ArrayList al = new ArrayList();
try
{
sr = new StreamReader(@"C:\temp\data.txt", Encoding.GetEncoding(932));
Hashtable uniqHash = new Hashtable();
while ((s = sr.ReadLine()) != null)
{
if (uniqHash[s] == null)
{
uniqHash[s] = true;
if (ngHash[s] == null) { al.Add(s); }
}
}
}
finally
{
if (sr != null) sr.Close();
}
//ソート
al.Sort();
//出力
StreamWriter sw = null;
try
{
sw = new StreamWriter(@"C:\temp\output.txt", false, Encoding.GetEncoding(932));
for (int i=0; i<al.Count; i++) { sw.WriteLine(al[i]); }
}
finally
{
if (sw != null) sw.Close();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}