Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9191545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:42:35+00:00 2026-06-17T20:42:35+00:00

I have a solution containing two projects. One project is just for doing all

  • 0

I have a solution containing two projects. One project is just for doing all data stuff and the other one, the startup project, do all the web stuff.

solution

Now I want to get the TasksDataBase.xml from the TaskManagerHelpers class by first getting the projects root directory. But all I get is the TaskManager.Web root directory. (I call the method inside TaskManagerHelpers.cs from a controller inside TaskManager.Web)

How do I get the TaskManager.Data root directory when I’m in a class in the same project?

I’ve tried with theese methodes and similar ones.

  • HttpContext.Current.Request.PhysicalApplicationPath;
  • System.IO.Path.GetFullPath();
  • AppDomain.CurrentDomain.BaseDirectory;

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:42:36+00:00Added an answer on June 17, 2026 at 8:42 pm

    One possibility is to embed the XML file into the assembly of the class library and then read it as resource in your web application. Remember that when you publish your web application to a web server all that will get into the package will be the files of this web application. There’s no physical relation to some projects that might have lived into the Visual Studio solution that this web application was part of.

    You may take a look at the GetManifestResourceStream method which will allow you to read the embedded XML from the referenced assembly.

    Here’s an example:

    // you could use any type from the assembly here
    var assembly = typeof(TaskManagerHelper).Assembly;
    using (var stream = assembly.GetManifestResourceStream("TaskManager.Data.DataBase.TasksDataBase.xml"))
    using (var xmlReader = XmlReader.Create(stream))
    {
        // ... do something with the XML here
    }
    

    Bear in mind though that since the file is embedded into the assembly you will not be able to modify it. It is readonly. If you need to modify it then an alternative approach would consist into copying this file to your web application. For example a good place is the App_Data special folder. You could even setup a post compilation step that will copy the XML file in this location.

    And then you can reference it easily:

    string xmlFile = HostingEnvironment.MapPath("~/App_Data/TasksDataBase.xml");
    using (var xmlReader = XmlReader.Create(xmlFile))
    {
        // ... do something with the XML here
    }
    

    In this case since the XML file is now physically part of the web application and lives on the hard drive you could also modify it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VS2008 solution containing two projects, a web service (the actual work
I have a solution containing a lot of projects and installer projects. One project
I have a .NET solution containing two projects: An ASP.NET MVC project, 'Website' A
I have a VS2008 solution containing two C++ projects. One is a Win32/console .dll
I have one solution in VS2010 containing two MVC 3 projects. These are two
So I have a VS 2010 solution containing one ASP.NET MVC 3 project and
I have a solution consisting of two projects: Project1 containing a single file program.cpp
I have a solution in Visual Studio 2010, containing two projects: A static library
I have a VC++ 2010 solution containing two projects: ProjectX and ProjectXTests. In the
I have an element containing two images, one layered on top of the other.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.