任何人都知道我怎么能绕过这个“不支持的例外”?
'Amends label2 to file name as text (works in conjunction with PART 00-AB form1)...
Label2.Text = "Project: " & Form1.Label5.Text & " could not be found"
'sugesting other related files in the folder...
Dim di As New IO.DirectoryInfo("v:\" & Label2.Text & "\Tekeningen\Tekenwerk De Mar\Definitief\" & Label2.Text & ".PDF")
Dim diar1 As IO.FileInfo() = di.GetFiles()
Dim dra As IO.FileInfo
For Each dra In diar1
If System.IO.Path.GetExtension(dra.Name).ToLower() = "pdf" Then
ListBox1.Items.Add(dra)
End If
Next
End Sub
答案 0 :(得分:2)
这意味着类DirectoryInfo
不支持您给出的路径。我必须是一个目录,似乎你正在尝试使用PDF文件。
也许你想要这样的东西:
Dim di As New IO.DirectoryInfo("v:\" & Label2.Text & "\Tekeningen\Tekenwerk De Mar\Definitief\")
顺便说一句,您可以使用它来更快地获取PDF文件,而无需检查文件夹中的所有文件:
DIm diar1 As IO.FileInfo() = di.GetFiles("*.pdf")