2013-02-18 83 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") 
相关问题