Errors appear in vb file only

D

DesCF

Below is a section from my aspx web page. If I create the same but place
the function GetPhotos() in a separate vb file I get the following errors
underlined in blue:

List(Of String) - Type 'List' is not defined
Directory - Name 'Directory' is not declared
Path - Name 'Path' is not declared

Does anyone know why this is? Have I missed something obvious?



<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections.Generic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">

Public Function GetPhotos() As List(Of String)
Dim photos As New List(Of String)()
Dim photoPath As String = MapPath("~/Photos")
Dim files As String() = Directory.GetFiles(photoPath)
For Each photo As String In files
photos.Add("~/Photos/" + Path.GetFileName(photo))
Next
Return photos
End Function
 
D

DesCF

Ok, I've sorted it out. I needed to put the following 2 lines at the top
of the vb file:

Imports System.IO
Imports System.Collections.Generic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top