Tuesday, March 13, 2012

Server.MapPath - Embarrasingly simple question

Hello All

I am trying to learn C# after having always worked with VB and I have come across a really stupid problem.

In VB.Net I know the code would be:

blah=Server.MapPath("files\" & Session("myFolder"))

in c# I have written it as

blah= Server.MapPath("files\" + Session["myFolder"])

but I get blue sqiggles under the "myFolder". what am I doing wrong?

Please Help!

Bex

The code has to be as

blah=Server.MapPath(@."files\" + Session["myFolder"].ToString());

Session variable has to be converted to string.

@. symbol used to handle string without escape sequence

0 comments:

Post a Comment