Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Path.Combine

Status
Not open for further replies.

drewj840

Programmer
Jan 19, 2003
5
US
I have always worked in VB but recently inherited a C# application. I decided not to convert it so that I can become familiar with C#. I have an issue using the Path.Combine method in that it seems to add an extraneous "@" character at the beginning of the string which throws off an error in Windows since there is no path that begins with "@". Here is the code:

state.ReportDir = Path.Combine(ConfigurationSettings.AppSettings["ReportsFolder"], state.ReportCode);

I confirmed using breakpoints that the value of ConfigurationSettings.AppSettings["ReportsFolder"] is "templates" and the value of state.ReportCode is "month", so the concatenated string (state.ReportDir) should be "templates\month". Instead it is @"templates\month" and I have no idea where the "@" is coming from.
 
Did you check the config file to see what is there? The @ sign is supposed to mean that the string will be taken literally, and since that value has a \ in it (the escape character), you can either escape the escape (i.e. "c:\\path\\folder\\file") or you can put an @ in front of the string (i.e. @"c:\path\folder\file").

Can you check and see if the person made a mistake? If the @ sign is in the config file, try taking it out and putting the double slashes in and see if you still have the problem.

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top