0

有人知道我如何解决这个“不支持的异常”吗?

'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
4

1 回答 1

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")
于 2013-02-18T08:15:38.157 回答