.Replace related problem
-
I am tring to replace "\" to "\\". e.g. -------------------------------------------------------- string strFName = ""; strFName = Application.StartupPath.ToString(); // Value get by above code is C:\UPLOAD\UPLOAD strFName = strFName.Replace("\","\\"); -------------------------------------------------------- But this code is not getting compile. KK
-
I am tring to replace "\" to "\\". e.g. -------------------------------------------------------- string strFName = ""; strFName = Application.StartupPath.ToString(); // Value get by above code is C:\UPLOAD\UPLOAD strFName = strFName.Replace("\","\\"); -------------------------------------------------------- But this code is not getting compile. KK
The slash indicates an escape sequence. If you don't want it interpreted as an escape sequence prefix the string literal with an @, e.g.
@"\"
-- Always write code as if the maintenance programmer were an axe murderer who knows where you live. Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o ... * Reading: SQL Bits My website
-
The slash indicates an escape sequence. If you don't want it interpreted as an escape sequence prefix the string literal with an @, e.g.
@"\"
-- Always write code as if the maintenance programmer were an axe murderer who knows where you live. Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o ... * Reading: SQL Bits My website