troubleshooting Question

Issues with Server.Mappath

Avatar of Star79
Star79Flag for United States of America asked on
.NET Programming
2 Comments1 Solution394 ViewsLast Modified:
Hello,

I am trying to use Server.Mappath in a Class library ( DLL Developed in C#).
After some research i found that i should be using the following command to get the Server path from the DLL.

System.Web.HttpContext.Current.Server.MapPath

I am using the following code

using System.Web;
using System.Web.UI;

String Filename;
Filename = System.Web.HttpContext.Current.Server.MapPath + "test.xml";

but I get this exception.
::Object reference not set to an instance of an object.

Your help will be appreciated.
Rithesh
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros