1

Im using C# to try save a file to an iis "temp" folder path, it works locally but wheh i publish the app and access it from another computer it uses the full path (C:/....) and cant find it as its looking for a local directory, how can i fix this?

(Server.MapPath("~/TEMP/") + filename); // code to savefile

Thanks

1
  • perhaps store the location of the temp upload folder location in the web.config appsettings Commented Apr 23, 2013 at 23:43

1 Answer 1

3

well a nice improvement you can do is:

1) add an absolute path as appSetting to your application web config, something like: \\MachineName\ShareName

2) create the ShareName network share on the machine MachineName (this could be your server where you publish the application or another server as well, up to your needs)

3) allow the IIS user or the application pool's identity user to access in read-write to the share: \\MachineName\ShareName

4) edit your code above to do something like:

Path.Combine(sharePath, filename);

where sharePath is a string initialized with the value from your web.config's appSetting using ConfigurationManager.AppSetting["settingName"]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.