CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Problem with string assignment escape character

    Hi,

    I am getting a escape character error when i assign a string to a text box with a '\' character

    eg:

    this.txtHeaderDirectory.Text = "C:\Temp";

    so later i added excape character ' but still it is not working.. it is displaying C:''temp.. I want C:\Temp to be displayed.. how to do ?

    thanks,

  2. #2
    Join Date
    May 2004
    Location
    Osijek
    Posts
    61

    Re: Problem with string assignment escape character

    Use @:
    Code:
    this.txtHeaderDirectory.Text = @"C:\Temp";
    Do notice that string will be saved as is (with one backspace), but it will be shown as two backspaces during debugging. This is quite normal.

  3. #3
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: Problem with string assignment escape character

    Code:
    this.txtHeaderDirectory.Text = "C:\\Temp"; // escape the backslash if you don't use the verbatim identifier (above)

  4. #4
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: Problem with string assignment escape character

    thanks it working fine now...

  5. #5
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Problem with string assignment escape character

    Fore more you can take a look here: http://msdn.microsoft.com/en-us/library/aa691090.aspx.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured