Ahmed Abd-elbaqi
Ahmed Abd-elbaqi

Reputation: 13

When to use Server Path

When i start to attach the same file to AdRotator object, it didn't work :

AdRotator1.AdvertisementFile = Server.MapPath("~/Data/Ads.xml");

Then i used, and it worked:

AdRotator1.AdvertisementFile = "~/Data/Ads.xml";

Can anyone tell me when to use Server.MapPath?

Upvotes: 1

Views: 397

Answers (2)

user7740728
user7740728

Reputation:

From Microsoft: The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.

So when you call Server.MapPath("~/Data/Ads.xml") it returns the complete path, including the directory on the server. But in your case, you probably just need the relative path, so you don´t need to call Server.MapPath.

Upvotes: 1

Przemysław Kleszcz
Przemysław Kleszcz

Reputation: 646

The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server

Upvotes: 1

Related Questions