locked
Pointing to a folder RRS feed

  • Question

  • User1210767569 posted

    I want to point to folder to loop through and get the files.

    The webpage URL where the asp is, is:

    http://website.info/gateway/admin/folder1/subfolder/testpage.aspx

    the files themselves are:

    http://website.info/gateway/folder1/subfolder/

    How do I 'get' to that folder using the below code?!

    Dim filePaths() As String = Directory.GetFiles(Server.MapPath("~/folder1/subfolder/"))
    
    Dim files As List(Of ListItem) = New List(Of ListItem)
    For Each filePath As String In filePaths
    files.Add(New ListItem(Path.GetFileName(filePath), filePath))
    Next
    GridView1.DataSource = files
    GridView1.DataBind()


    Thank you in advance

    Tuesday, October 22, 2013 10:30 AM

Answers

  • User-18289217 posted
    For Each file As String In IO.Directory.GetFiles(Server.MapPath("~/gateway/folder1/subfolder"))
       Dim finfo As New IO.FileInfo(file)
       Response.Write("File name and its path: " & finfo.FullName & "<br />")
       Response.Write("File name without its path: " & finfo.Name & "<br /><br />")
    Next

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 22, 2013 4:01 PM

All replies

  • User-851967432 posted

    To my knowledge, you can do that via UNC. It has be a physical local path but I could be wrong.

    Tuesday, October 22, 2013 3:19 PM
  • User-18289217 posted
    For Each file As String In IO.Directory.GetFiles(Server.MapPath("~/gateway/folder1/subfolder"))
       Dim finfo As New IO.FileInfo(file)
       Response.Write("File name and its path: " & finfo.FullName & "<br />")
       Response.Write("File name without its path: " & finfo.Name & "<br /><br />")
    Next

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 22, 2013 4:01 PM