Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
String[] files = Directory.GetFileSystemEntries(directoryToSearch, fileNameToFind, SearchOption.AllDirectories());
就像错误所说的那样,您不能SearchOption.AllDirectories作为方法调用,因为它不是方法。我想你想要这个:
SearchOption.AllDirectories
String[] files = Directory.GetFileSystemEntries(directoryToSearch, fileNameToFind, SearchOption.AllDirectories);
在某事后加上括号告诉编译器它应该将该某事作为方法执行。所以你基本上只是混淆了编译器。 SearchOption.AllDirectories是一个值,而不是一个方法。