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
.NET ProgrammingMicrosoft DevelopmentWCF

Avatar of undefined
Last Comment
kaufmed

8/22/2022 - Mon
Gautham Janardhan

you want to do this in the WCF service ?
razza_b

ASKER
yes thats where it will be.
razza_b

ASKER
i need to point to a repo..

"\\SR-SCO-D10\\Labels\\Labels.tfr"
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Gautham Janardhan

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
Nitesh Luharuka

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
razza_b

ASKER
Hi i wont be back online until monday to try examples, niteshl what is your example like?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Nitesh Luharuka

Razza,

Did not get your question..
Sanjay87

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
ExpertLogin_890

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);
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
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
kaufmed

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

ASKER
Hi kaufmed in what way would it be used?

Just assign the server path like form.repo = unc server path ??
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
kaufmed

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question