views:

25

answers:

1

Ok, I know that question is not very informative.. Someome feel free to change it after I explain:

My asp.net mvc project is stored in a folder in my desktop. When I double click on the sln or csproj to open the project and then hit the Start Debuggin button it all works fine.

But, when I go to start, programs and open Visual Web developer and from the Recent Projects I open the same project and Start debugging I get a read file error (could not find part of the path in C:\Program files(x86)\Microsoft Visual.......")

Its in this line of code btw. this.nav = XElement.Load("App_Data/myfile.xml");

It obviously is looking on the wrong directory cause the project folder is in my desktop. Keep in mind that it works just fine if I access the project by just double clicking on the csproj file.

Thanks in advance.

A: 

You can't rely on the working folder for the process in ASP.NET applications. You should be resolving a relative path in code:-

this.nav = XElement.Load(HttpContext.Current.Server.MapPath("App_Data/myfile.xml"));

However introducing the HttpContext object can damage the testability of your code, if this in controller code.

AnthonyWJones
Its not, its in a model
NachoF