2010-08-04 5 views
0
Function getItems() 
     ''# make a reference to a directory 
     Dim di As New IO.DirectoryInfo("https://ipossum.svn.sourceforge.net/svnroot/ipossum/") 
     Dim diar1 As IO.FileInfo() = di.GetFiles() 
     Dim dra As IO.FileInfo 

     ''#list the names of all files in the specified directory 
     For Each dra In diar1 
      ListBox1.Items.Add(dra) 
     Next 
    End Function 

그건 내 코드이고 작동하지 않습니다. 오류는 "Warning 1 Function 'getItems' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. C:\Users\******\AppData\Local\Temporary Projects\iPossum\Form1.vb 13 5 iPossum"입니다.SourceForge SVN 프로젝트의 폴더에서 항목 가져 오기

어떻게하면됩니까? 감사!

답변

2

묻는 오류를 수정하려면 FunctionSub으로 변경하십시오.

그러나 이렇게하면 코드가 작동하지 않습니다. System.IO 디렉토리 및 파일 클래스는 로컬 파일 시스템에서만 작동하기 때문에 새로운 오류가 발생합니다. 그렇게하면 원격 https 위치를 참조 할 수 없습니다. 대신 System.Net.HttpWebRequest/System.Net.HttpWebResponse 또는 System.Net.WebClient를 사용해야하며 이는 기본적으로 처음부터이 코드로 시작한다는 것을 의미합니다. 난 당신이 할 수 있다면, 모든 종류의 파일을 요청과 함께 위대한 아니에요

Dim fileList As String 
Using wc As New WebClient 
    fileList = wc.DownloadString("https://ipossum.svn.sourceforge.net/svnroot/ipossum/") 
End Using 
''# Here you'll have to parse the file names out of this response on your own 
+0

하고 있습니다 또는 작업 HTTPS 요구 사항에 따라하지 않을 수도 있습니다


아주 간단한 예 시간을 내게 쓸 수 있니? –

관련 문제