c#遍历查找指定文件

 private Regex nameRx = new Regex(@"([\w\W]*?).(doc|docx)",RegexOptions.IgnoreCase);
private void FildDoc(string path)
{
  DirectoryInfo directory = new DirectoryInfo(path);
    FileSystemInfo[] fileSystemInfos = directory.GetFileSystemInfos();
     foreach (FileSystemInfo filess in fileSystemInfos)
     {
         if (fileSystemInfo is DirectoryInfo)
         {
            FildDoc( path);
         }
         else if (fileSystemInfo is FileInfo)
         {
           string fileName = fileInfo.Name;
           if (nameRx.Match(fileName).Success)
           {
            //找到word文档了;
           }
         }
     }
}

posted @ 2011-09-23 13:54  落冰  阅读(1064)  评论(0编辑  收藏  举报