有没有办法访问第二个生成的文件夹? 我试过了
var lastDirectory = new DirectoryInfo(path).GetDirectories("*",
SearchOption.AllDirectories).OrderByDescending(x => x.LastWriteTimeUtc).Second();
但它没有用。
如果你能给我一个解决方案,我会很感激。
答案 0 :(得分:4)
使用FirstOrDefault()
跳过第一个元素,然后使用var lastDirectory = new DirectoryInfo(path).GetDirectories("*",
SearchOption.AllDirectories).OrderByDescending(x => x.LastWriteTimeUtc)
.Skip(1).FirstOrDefault();
获取第二个元素,如果没有,则使用默认值
ElementAtOrDefault
或者您可以使用var lastDirectory = new DirectoryInfo(path).GetDirectories("*",
SearchOption.AllDirectories).OrderByDescending(x => x.LastWriteTimeUtc)
.ElementAtOrDefault(1);
:
{
"HiServiceInquiryResponse": {
"CoverageInfoResponse": {
"Participant": {
"ns1:PersonalInfo": {
"ns1:LastName": "AA",
"ns1:Address": [
{
"ns1:Province": "",
"ns1:State": "CA",
"ns1:City": "LOS ANGELES",
"ns1:Country": "US",
"ns1:Address2": "",
"ns1:Address1": "test",
"ns1:PostalCode": 12345
},
{
"ns1:Province": "",
"ns1:State": "CA",
"ns1:City": "LOS ANGELES",
"ns1:Country": "US",
"ns1:Address2": "",
"ns1:Address1": "test",
"ns1:PostalCode": 12345
}
],
"ns1:FirstName": "BB"
},
"ns1:Coverage": "",
"ns1:HiClientId": 57,
"ns1:Employment": {
"ns1:EmployeeId": 1234,
"ns1:TaxId": 111
}
}
}
}