How to use Server.Mappath

Last post 07-01-2009 9:11 AM by navi6975. 3 replies.

Sort Posts:

  • How to use Server.Mappath

    06-26-2009, 12:42 PM
    • Member
      2 point Member
    • navi6975
    • Member since 09-03-2008, 1:46 PM
    • Posts 8

    Hi Friends,

    my code is 

    Dim

    fs As FileStream = New FileStream("C:\Documents and Settings\C100492\Desktop\Docs\sampleWS\xmls\" & GadgetName & ".xml", FileMode.Open, FileAccess.Read)

    In the above code I have to change the phisical path(C:\Document.............) with Server.mappath.

    Plz. let me know how to write the same code with Server.mappath. I have all xml files in my local application folder(folder name:XML).

     

  • Re: How to use Server.Mappath

    06-26-2009, 1:00 PM
    Answer
    • Participant
      1,447 point Participant
    • DrivenTooFar
    • Member since 12-27-2007, 9:18 PM
    • Atlanta, GA
    • Posts 228
    What is the root of this project called?  I am going to assume that it is sampleWS.  That being the case:
    Dim fs As FileStream = New FileStream(Server.MapPath("xmls\" & GadgetName & ".xml"), FileMode.Open, FileAccess.Read)


     

    Please mark anything that helped you out as an answer.

    If you needed VB.NET and I gave you see C#, convert your code here.
  • Re: How to use Server.Mappath

    06-29-2009, 3:30 AM
    Answer

    Hi,

    It seems that the xml files are not in the directory of your website. If so, we do not recommend you to use Server.MapPath to fetch the path of files. Copy the folder storing the xml files into your website folder and use the method to get them then.

    For more information about this method, please refer to this link: http://msdn.microsoft.com/en-us/library/ms524632.aspx.

    Best Regards,
    Shengqing Yang

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread : )
  • Re: How to use Server.Mappath

    07-01-2009, 9:11 AM
    • Member
      2 point Member
    • navi6975
    • Member since 09-03-2008, 1:46 PM
    • Posts 8

    thanks DrivenTooFar................Its working. 

Page 1 of 1 (4 items)