Getting info from XML files in my Data Layer RRS feed

  • Question

  • User-140701587 posted

    Hi, i got a 3 layer web app.

    My DAL is a project that get info from Database.

    Id like to add funcionality for getting info from XML files that are in a particular folder.

    Problem is that for loading XML i got to code Server.MapPath so i got to use System.Web, id like not to use System.Web in DAL.

    So, how could i get info from XML in DAL knowing that there are several XML and that i dont use LINQ

    Thanks in advance.

    Thursday, April 18, 2013 1:57 PM


  • User477186420 posted

    There are few ways to getting path into class library, check below code that will help you

    //get the full location of the assembly with DaoTests in it
    string fullPath = System.Reflection.Assembly.GetAssembly(typeof(DaoTests)).Location;
    //get the folder that's in
    string theDirectory = Path.GetDirectoryName( fullPath );

    var assembly = Assembly.GetExecutingAssembly();
    var path = assembly.Location;

    string file = (new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;

    let me know if any query

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 19, 2013 1:23 AM