我收到错误“索引(从零开始)必须大于或等于零且小于参数列表的大小。” 我不知道为什么。
我的代码如下:
'read directory and look for filenames that match pattern and have code elements from xml file
Dim regElemName As New Regex("^code")
Dim root = XElement.Load(xmlfile)
Dim codeElements = root.Element("ApplicationSettings").Elements().Where(Function(xe) regElemName.IsMatch(xe.Name.LocalName)).Select(Function(xe) xe.Value)
Dim codes = String.Join("|", codeElements.ToArray())
Dim regFileName As New Regex(String.Format("^\d{5}\-(?<Year>(?:\d{4}))(?<Month>0?[1-9]|12|11|10)(?<Day>[12]\d|0?[1-9]|3[01])\-$", codes))
Dim files = IO.Directory.GetFiles(TextBox1.Text, "*.pdf", IO.SearchOption.TopDirectoryOnly).Where(Function(path) regFileName.IsMatch(IO.Path.GetFileName(path)))
For Each file As String In files
Console.WriteLine(file)
Next
有任何想法吗?