Reputation: 439
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
Upvotes: 1
Views: 1955
Reputation: 44605
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"]
Upvotes: 3