如题

解决方案 »

  1.   

    new DirectoryInfo("path").GetFiles().Length
      

  2.   

    System.IO.Directory.GetFiles("C:\1","",SearchOption.AllDirectories).Length
      

  3.   

    int count = 0;//文件总数
    string path = "....";//文件夹路径
    DirectotyInfo dir = new DirectoryInfo(path);
    foreach(FileInfo f in dir.getfile()) count++;
      

  4.   

    估计楼主问的是所有文件,楼上未考虑子文件夹。
    像楼上那样GetFiles的同时GetDirectories,然后遍历获取的Directories,递归调用取得子文件夹的文件,都加到一个int上就得到你想要的了。