Link to home
Start Free TrialLog in
Avatar of razza_b
razza_b

asked on

server mappath C#

Hi

Does anyone know how to use the server mappath in a silverlight 4 enabled wcf?

Thanks
Avatar of Gautham Janardhan
Gautham Janardhan

you want to do this in the WCF service ?
Avatar of razza_b

ASKER

yes thats where it will be.
Avatar of razza_b

ASKER

i need to point to a repo..

"\\SR-SCO-D10\\Labels\\Labels.tfr"
if it's hosted in asp .net web , then something like this should work,

HttpContext.Current.Server.MapPath("~/somefile.txt");

remeber that [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

atribute should be there
You can return a string from WCF Service similar as HttpContent.Current.Server.MapPath("~/Labels/Labels.tfr") and get the value in SL calling the same service
Avatar of razza_b

ASKER

Hi i wont be back online until monday to try examples, niteshl what is your example like?
Razza,

Did not get your question..
Hai ,
       HttpContext.Current.Server.MapPath(".") will give you the current working directory.
HttpContext.Current.Server.MapPath("~/App_Data/sample.tcl");
Or you can use like this also ,
HostingEnvironment.MapPath(".");

You can follow this link also ,
http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx
when you are doing with asp.net you can user mappath function as shown below

HttpContext.Current.Server.MapPath("~/somefile.txt");

other wise you want to do in silverlight and wcf ria services use below syntax,

string filepath = HostingEnvironment.MapPath(filename);
        FileInfo fi = new FileInfo(filenpath);
Avatar of razza_b

ASKER

Hi Guys thanks for all your feedback.

i need to use UNC \\ rather than ~ relative path

so if the repo.tfr resides in e.g. 10.148.22.35 server and within the C:\...\...\Labels.tfr directory

could i still get access? and i think i might need to use this if its for silverlight wcf...
form.Repository = HostingEnvironment.MapPath("\\..\..\..\")


Thanks
You wouldn't need to use MapPath on a UNC...  A UNC is an absolute path  = )
Avatar of razza_b

ASKER

Hi kaufmed in what way would it be used?

Just assign the server path like form.repo = unc server path ??
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial