我有一个简单的程序.它运行.NET 4.5并在Visual Studio 2013中构建.
D:\\MyDir充满了.xlsx文件,没有.xls文件.当我在Windows 8.1 x64上运行该程序时,过滤器*.xls不返回任何结果.当我在Windows 7 x86上使用相同的.NET版本运行相同的程序时,*.xls过滤器返回与过滤器相同的结果*.xlsx.
两个系统上的测试文件夹肯定包含相同的数据.
我错过了什么,或者这是.NET和/或Windows中的错误?
各自的代码:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace throw_test
{
static class Program
{
static void Main()
{
int fileCount1 = Directory.GetFiles("D:\\MyDir", "*.xlsx").Length;
int fileCount2 = Directory.GetFiles("D:\\MyDir", "*.xls").Length;
Console.WriteLine("File Count 1: " + fileCount1);
Console.WriteLine("File Count 2: " + fileCount2);
Console.Read();
}
}
}
Run Code Online (Sandbox Code Playgroud)
编辑1
当我使用Windows 8.1 x64中的命令提示符导航到该目录时:
dir *.xlsx …