views:

15

answers:

1
   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

That is my code and it did not work. The error was "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".

How do I do this? Thanks!

+1  A: 

To fix the error you're asking about, just change the word Function to Sub.

However, after you do this you're code still won't work. You'll have a new error, because the System.IO directory and file classes only work on the local file system. You can't reference a remote https location that way. You'll need to use System.Net.HttpWebRequest/System.Net.HttpWebResponse or System.Net.WebClient instead, and that means essentially starting from scratch with this code.


A very simple example that may or may not work, depending on the https requirement:

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
Joel Coehoorn
I'm not that great with requesting files of any type, if you could, and have the time could you write me the snippet?
Anonymous the Great