Escape Sequence Character Doubles (\ ends up as \\)

Hi,

When attempting to pass a file name and path to a textbox to use as a URL the following code:

string strURL =@"e:\jb.pdf";

Always sets strURL to e:\\jb.pdf

Using the @ symbol is supposed to force the compiler to ignore any escape characters.

Any ideas?

TIA

J

[468 byte] By [Dracoman] at [2007-12-24]
# 1

it probably does but only shows it in the IDE like that, but if you tried to perform some operations then it will treat it like how you would expect it to I believe.

What problems are you having? Windows will usually automatically get rid of the unneeded backslashes when say, opening a file in a process or something

ahmedilyas at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# General...
# 2

You are absolutely correct!

Thanks for your post. It made me go back and take another look. When I examined the string it does show both \\ characters but that was not my problem. The next line assigns the string value to a textbox that is an item on a toolstrip. When I referenced the textbox I forgot about the zero-based reference and I was actually getting an out of range error because I was attempting to assign the value to [7] where Devil was the highest index.

I saw the error, misinterpreted the nature of the string that I saw and proceded to my an amaturish mistake.

Thanks again. Who knows how long I would have run in circles!

Dracoman at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# General...