Double backslashes appearing in string path C#
Posted on 2011-02-12
I have a application that was working perfectly, i have just moved my website to a different server and the save path of created xml files has changed, instead of having it hard coded, i decided to place the path in the appsettings so i could edit it in the future if the path ever changed again, without having to recompile.
my problem is that when the path is getting picked up from the web config, the backslashes are being duplicated and the application doesnt see the path as a legitimate windows path giving the following error
The given path's format is not supported.
How can i stop this from happening.
Code in webconfig
<add key="SaveLocation" value="c:\home\c\o\complus\www\"/>
picked up in the code like so:
string savelocation = System.Configuration.ConfigurationManager.AppSettings["SaveLocation"].ToString();