2013-02-18 76 views
0

劑量任何人都知道我可以解決這個「不支持異常」?VB.NET「不支持異常」?

'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 
+2

那麼哪條線拋出異常? (這裏的內容是什麼 - 網絡應用程序?WinForms?) – 2013-02-18 07:19:58

+0

oops Dim di As New IO.DirectoryInfo(「v:\」&Label2.Text&「\ Tekeningen \ Tekenwerk De Mar \ Definitief \」&Label2.Text&「 .PDF「)其winform – 2013-02-18 07:21:33

+2

你真的有一個.pdf擴展名的目錄? – 2013-02-18 07:31:22

回答

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")