Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

asp.net problem

  • 30-05-2006 02:01PM
    #1
    Registered Users, Registered Users 2 Posts: 77 ✭✭


    Hi folks, I'm using web matrix at the moment and I would like to display the files from a particular folder in a listbox, would anyone be able to help me???


Comments

  • Registered Users, Registered Users 2 Posts: 872 ✭✭✭grahamor


    what do you mean, a particular folder in the website or on your desktop ?

    You should probably write an xml page that has the name of the file and the reference to where it is and then bind the xml file to the listbox control.

    I am familiar doing this with databases but not any other way

    edit: you should download visual web developer 2005 aswell (it's free), web matrix is discontinued and shi*te because there is no predicitive code writing (intellisense) which will save you so much time


  • Registered Users, Registered Users 2 Posts: 684 ✭✭✭Gosh


    This should do .. just call it for each folder (with the full path name)
    Sub BuildFileList(strFolder)
       Set oFolder = oFS.getFolder(strFolder)
       Echo("<SELECT NAME=filelist>")
       For Each FileName in oFolder.Files
          Echo("<OPTION VALUE=" & Chr(34) & FileName.Name _
          & Chr(34) & ">" & FileName.Name & "</OPTION>")
       Next
       Echo ("</SELECT>")
       Set oFolder = Nothing
    End Sub
    


  • Registered Users, Registered Users 2 Posts: 77 ✭✭peteym


    The folder is located on a shared drive - trying to download microsoft web developer thingy but for some reason won't install for me.

    Thanks for your help guys


  • Closed Accounts Posts: 140 ✭✭Sneaky_Russian


    in the page load, you could do something like so to list the files in the current directory
    if(!IsPostBack)
        foreach(string filename in System.IO.Directory.GetFiles(Server.MapPath("~/")))
            ListBox1.Items.Add(new ListItem(filename));
    
    


Advertisement