Server.MapPath

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ats@jbex

    Server.MapPath

    Hi there. I have a folder named reports on my web server. Inside the folder
    is a page named reports.aspx and 2 folders named client1 and client2. I
    have some spreadsheets in each of the folders that are relative to each
    individual client. I would like to know how I can use server.mappath to
    choose the correct folder depending on which client is logged. For example
    I would have the following code on my page behind:

    <CODE>
    Dim dirReo as New DirectoryInfo

    Select case client
    case client 1
    dirInfo = Server.MapPath( ???)

    case client 2
    dirInfo = Server.MapPath( ???)

    end select

    reportList.Data Source = dirInfo.GetFile s("*.xls")
    reportList.Data Bind
    <END CODE

    What do I need to put in the brackets to replace the ???
    --
    ats@jbex

    When an old lady got hit by a truck
    I saw the wicked gleam in your eyes

    Adam and The Ants - Whip In My Valise
  • =?Utf-8?B?Q3lib3JneDM3?=

    #2
    RE: Server.MapPath

    You can use the tilde character ("~") to specify the root of you
    rapplication. For example, if your reports folder is located at the root
    level of your app, you could use Server.MapPath( "~/reports/client1") which
    will return a string representation of the physical path (i.e.,
    "C:\inetpub\www root", etc) to the folder specified.

    You could then use a DirectoryInfo object to find the files you are looking
    for.

    Example Code:

    Dim pathToFolder as String = Server.MapPath( "~/reports/" & client)

    Dim d As DirectoryInfo = New DirectoryInfo(p athToFolder)
    d.GetFiles("*.x ls")


    "ats@jbex" wrote:
    Hi there. I have a folder named reports on my web server. Inside the folder
    is a page named reports.aspx and 2 folders named client1 and client2. I
    have some spreadsheets in each of the folders that are relative to each
    individual client. I would like to know how I can use server.mappath to
    choose the correct folder depending on which client is logged. For example
    I would have the following code on my page behind:
    >
    <CODE>
    Dim dirReo as New DirectoryInfo
    >
    Select case client
    case client 1
    dirInfo = Server.MapPath( ???)
    >
    case client 2
    dirInfo = Server.MapPath( ???)
    >
    end select
    >
    reportList.Data Source = dirInfo.GetFile s("*.xls")
    reportList.Data Bind
    <END CODE
    >
    What do I need to put in the brackets to replace the ???
    --
    ats@jbex
    >
    When an old lady got hit by a truck
    I saw the wicked gleam in your eyes
    >
    Adam and The Ants - Whip In My Valise
    >

    Comment

    Working...