C# 按最后10个字符的顺序获取文件列表

C# 按最后10个字符的顺序获取文件列表,c#,.net,C#,.net,我希望按照文件名最后10个字符的顺序对文件进行排序,我希望在一条指令中完成这项工作 // this works string s = "...blabla20140129.u", s2 = s.Substring(s.Length - 10,8); // this fails with the message var directory = new DirectoryInfo(dir).GetFiles(fileSpec).OrderBy(f => f.FullName.Substri

我希望按照文件名最后10个字符的顺序对文件进行排序,我希望在一条指令中完成这项工作

// this works

string s = "...blabla20140129.u", s2 = s.Substring(s.Length - 10,8);

// this fails with the message
var directory = new DirectoryInfo(dir).GetFiles(fileSpec).OrderBy(f => f.FullName.Substring(f.FullName.Length - 10),8);

Error   1   The type arguments for method 'System.Linq.Enumerable.OrderBy<TSource,TKey>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,TKey>, System.Collections.Generic.IComparer<TKey>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.   
//这很管用
字符串s=“…blabla20140129.u”,s2=s.子字符串(s.长度-10,8);
//这将与消息一起失败
var directory=newdirectoryinfo(dir).GetFiles(fileSpec).OrderBy(f=>f.FullName.Substring(f.FullName.Length-10),8);
错误1无法从用法推断方法“System.Linq.Enumerable.OrderBy(System.Collections.Generic.IEnumerable,System.Func,System.Collections.Generic.IComparer)”的类型参数。尝试显式指定类型参数。
必须使用.net 3.5或更低版本解决此问题


非常感谢您的建议。

您只是把括号放错了位置:

.OrderBy(f => f.FullName.Substring(f.FullName.Length - 10, 8));