dc

dc

  • NA
  • 663
  • 0

C# app.config for directory location

Jan 29 2013 8:31 AM
I have a question about 2 C# 2010 windows applications that I am running:

In one program I am <appSettings>
<add key="FileLocation" value="D:App\Staging" />
</appSettings>

String filesaveLocation = null;
                filesaveLocation = ConfigurationSettings.AppSettings["FileLocation"] + "\\" + Format_Date + "\\";
                if (Directory.Exists(filesaveLocation))
The above works.

In the other program I am using
<appSettings>
< add key="FileLocation" value="D:App\\Staging"  />
< /appSettings>
String filesaveLocation =  null;
                 filesaveLocation = ConfigurationSettings.AppSettings["FileLocation"] + "\\" +  Format_Date +  "\\";
                 if (Directory.Exists(filesaveLocation))
this works fine on my windows 7 workstattion.

However when I move the code to a production server, the code does not work.

Do I need to have the '\\" in the directory path set to a different value?

Thus can you tell me what you think could be going wrong and show me code on how to solve the problem?

Answers (1)