kihoshk@gmail.com <kihoshk@gmail.com> wrote:[color=blue]
> I have what I THINK is an incredibly simple question, though I can't
> resolve it.
>
> I have a reference that returns a string which oftentimes contains "\".
> These returned strings ar produced by a DLL, which is out of my
> control. The string is assigned to a variable:
>
> string returnedValue;
> returnedValue=Encrypt("my data");
> (returnedValue is assigned something like "x9wk2\nSjsk"; notice the
> "\n")
>
> I need the string to be interpereted literally elsewhere in my code
> (it's being injected into a table, and the escape-sequences are being
> processed in the queries and erroring-out the commands), but when I try
> to convert the escape-sequence character, nothing changes:
>
> returnedValue=returnedValue.Replace("\\","\\\\")
> -or-
> returnedValue=returnedValue.Replace(@"\",@"\\")
>
> (returnedValue is still "x9wk2\nSjsk")
>
> I'm tearing my hair out here; what am I missing?[/color]
What exactly is processing the queries? If it's a SQL query, you should
use SQL parameters instead. Unless it's actually a C# compiler, you
almost certainly don't want to perform the same escaping as C# needs...
--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too