Anousha Khan
Anousha Khan

Reputation: 13

Load File from root directory

I want to load my dic.xml file from the root folder , as now I am giving the full path in my application but i want a file loaded from the root directory.

var doc = XDocument.Load(@"D:\anu notes\FYP\LSC 1\LSC 1\LSC\LSC\dic.xml");

Upvotes: 0

Views: 627

Answers (1)

Marko Popovic
Marko Popovic

Reputation: 4153

Here is what you need:

var rootFolder = System.IO.Path.GetDirectoryName(
    System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
var xmlFilePath = rootFolder + @"\dic.xml";
var doc = XDocument.Load(xmlFilePath);

Upvotes: 1

Related Questions