ASP.NET C# Relative path

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chathura86
    New Member
    • May 2007
    • 227

    ASP.NET C# Relative path

    I'm new to ASP.NET
    i'm new to asp.net

    i created a class which reads a xml file
    placed the class in the app_code folder and placed the xml file in another folder
    both folders are in the root

    now i want to give the relative path to this xml file but when the project build
    the relative path is set to system32 folder

    seems the compiled class is saved in the system32 folder

    how can i give the relative path to xml file

    when i placed the class file in another folder other than the app_code
    id does not compiled into the bin folder as usual

    please help me

    chathura bamunusinghe
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Well, in your ASP.NET codebehind, you can get the physical path from a relative path by using Server.MapPath( "/relativePath/");

    I would modify my class to take a path as a parameter of the constructor. Then pass the value of Server.MapPath( "/pathToYourFile. xml");

    Comment

    • chathura86
      New Member
      • May 2007
      • 227

      #3
      Thanks for the replay

      i found this

      HttpContext.Cur rent.Server.Map Path("~/App_Data/settings.xml")

      it works well also.

      may be both are the same im not sure

      Comment

      Working...