Carlos Sanchez

Carlos Sanchez

  • NA
  • 264
  • 0

How to concatenate a backslash?

Oct 1 2004 12:18 PM
Hi all! I have a condition that compare two strings n' I heve a problem to concatenate. I heve the below condition: if (myFileInfo.DirectoryName + "\\" != MyPath) The result of the condition must be true but it doesn't run the if statement. I've inserted a breakpoint in this line and the values are the next: myFileInfo.DirectoryName = "C:\Program Files" MyPath = "C:\Program Files\" myFileInfo.DirectoryName + "\\" = "C:\Program Files\\" The problem is the doble backslash. If I write only one (... + "\") an exception is thrown. I tried with the verbatim symbol (... + @"\") n' in the breakpoint the values are the next: myFileInfo.DirectoryName = "C:\Program Files" MyPath = "C:\Program Files\" myFileInfo.DirectoryName + @"\" = error: maneged EE does not understand the expression's syntax Any idea? Taking in mind that I have others conditions n' if I modify Mypath string in the others condition I'd have the same problem) Thanx in advance Regards

Answers (3)