Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Invalid path for MapPath. A virtual path is expected VB.Net

  • 14-06-2006 8:31am
    #1
    Registered Users, Registered Users 2 Posts: 7,989 ✭✭✭


    Hi,

    I am getting the following error when i am trying to create the file.

    The code is falling over on the following line

    Dim s As New StreamWriter(Server.MapPath(strFileName))

    Invalid path for MapPath 'e:\inetpub\wwwroot\internet site\quotes\clikpayorders\771001843-000011.ord'. A virtual path is expected

    Can someone help me please
    Private CLICK_PAY_F As String = esConfig.getSetting("ClickPayF")
    Private MERCHANT_ID As String = esConfig.getSetting("MerchantID")
    Dim f As File
    Dim strFileName As String
    Dim strOrderDetail As String
    
    strFileName = CLICK_PAY_F & MERCHANT_ID & "-" & strHexNumber & ".ord"
    
    Dim s As New StreamWriter(Server.MapPath(strFileName))
    
    s.Write(strOrderDetail)
    
    


Comments

  • Closed Accounts Posts: 522 ✭✭✭comer_97


    if you have the full path (e:\inetpub\wwwroot\internet site\quotes\clikpayorders\771001843-000011.ord) you don't need to use server.mappath

    server.mappath should get you (e:\inetpub\wwwroot\internet site\quotes\clikpayorders\771001843-000011.ord)

    you could do server.mappath("771001843-000011.ord") if it is the same folder as the code that is running or something like server.mappath("/site/quotes/clikpayorders/771001843-000011.ord")

    or alternatively you can get rid of server.mappath and just have the filename in there.


  • Closed Accounts Posts: 1 navnia


    Hi people. I would like to seek for help on how to use Server.MapPath("./") to store the file uploaded in an external server. Really hoping for a step by step guidance as i am really new to all this. I am looking forward for help from all the experts out there. Please do reply me..;) tk care..thanking in advance.


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    navnia wrote:
    Hi people. I would like to seek for help on how to use Server.MapPath("./") to store the file uploaded in an external server. Really hoping for a step by step guidance as i am really new to all this. I am looking forward for help from all the experts out there. Please do reply me..;) tk care..thanking in advance.

    As far as I am aware, Server.MapPath can only be used to reference locations on that server - and not on an external one.

    What exactly are you trying to do?


  • Closed Accounts Posts: 250 ✭✭GP


    Try using the ~

    I had simialr problems trying to upload images at one stage.


    Absolute and relative path references in a server control have the following disadvantages:

    Absolute paths are not portable between applications. If you move the application that the absolute path points to, the links will break.

    Relative paths in the style of client elements can be difficult to maintain if you move resources or pages to different folders.



    ASP.NET includes the Web application root operator (~), which you can use when specifying a path in server controls. ASP.NET resolves the ~ operator to the root of the current application. You can use the ~ operator in conjunction with folders to specify a path that is based on the current root.


Advertisement