Re: Find file names from /image folder at load

Discussion in 'ASP .Net' started by CodeMeister, May 15, 2004.

  1. CodeMeister

    CodeMeister Guest

    Try the following:

    <script language="vb" runat="server">
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    Dim strFiles() As String =
    System.IO.Directory.GetFiles(Server.MapPath("img"))
    For Each file In strfiles
    Response.Write("<!--" & file & "-->")
    Next
    End Sub

    "Zak PEloquin via .NET 247" <> wrote in message
    news:...
    I'm trying to get file names from the /image folder. The folder contents are
    dynamic. After I get the file names, I'm running some VB on them that writes
    out dynamically created JScript (for mouse rollover). When I try to find the
    files in the folder, I get the following error:

    BC30451: Name 'Directory' is not declared.

    The index.aspx page code is (truncated):

    <script language="vb" runat="server">
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    Dim strFiles() As String = Directory.GetFiles("img")
    For Each file In strfiles
    Response.Write("<!--" & file & "-->")
    Next
    End Sub

    The index.aspx.vb code is (truncated):

    Imports System.IO

    Public Class index

    Inherits System.Web.UI.Page
    Protected WithEvents tblMain As System.Web.UI.WebControls.Table
    Protected StartHead As HtmlGenericControl

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load

    End Sub
    End Class

    I saw a number of other requests for help, but I wasn't able to help myself
    using only the advice of 'use the System.IO.Directory namespace'. I'm pretty
    new to VB, I guess (18 mos.) because the MSDN page on this namespace didn't
    help me either.

    -Zak

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>TcbY0uairEmtROtzNHezuQ==</Id>
     
    CodeMeister, May 15, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CT
    Replies:
    0
    Views:
    452
  2. Mike John
    Replies:
    0
    Views:
    515
    Mike John
    Jul 28, 2003
  3. Filip De Backer

    Image doesn't load and security on folder is the cause??

    Filip De Backer, Jan 27, 2005, in forum: ASP .Net Security
    Replies:
    6
    Views:
    137
    Ken Schaefer
    Jan 28, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    413
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    815
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page