checkName

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows;


namespace CheckName
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                string[] collection = File.ReadAllLines("name.txt", Encoding.Default);
                string[] files = Directory.GetFiles(Directory.GetCurrentDirectory());
                List<string> list = new List<string>();
                List<string> list2 = new List<string>();
                list.AddRange(collection);
                for (int i = 0; i < list.Count; i++)
                {
                    int index = 0;
                    while (index < files.Length)
                    {
                        if (files[index].Contains(list[i]))
                        {
                            break;
                        }
                        index++;
                    }
                    if (index == files.Length)
                    {
                        list2.Add(list[i]);
                    }
                }
                File.WriteAllLines("作业名单.txt", list2.ToArray());
            }
            catch (Exception)
            {
               
                throw;
            }
           

        }
    }
}


原文链接: http://blog.csdn.net/mypc2010/article/details/7950110

你可能感兴趣的:(checkName)