我需要找到一个 Excel 文件。但是,我正在寻找的文件的扩展名可能是 .xls 或 .xlsx。我正在考虑使用 FileExists,但我不能使用通配符。这是我尝试使用 GetFiles,但是,.xls* 部分我的代码不起作用。我以前从未使用过 GetFiles,谁能给我一些关于我做错了什么的指导?
Dim InputFormPath As String = "W:\TOM\ERIC\NET Dev\"
Dim wbNameXLSInputForm As String = StatVar.xlApp.Sheets("New Calculator Input").Range("D15").Text & ".xls*"
Dim XLSInputForm As String = wbNameXLSInputForm
Dim dirs As String() = Directory.GetFiles(InputFormPath, wbNameXLSInputForm)
If dirs.Length <> 0 Then
'do something
End If