Re: Error in c# project: Unrecognized escape sequence

Discussion in 'Microsoft Dot NET' started by Chris R. Timmons, Jul 7, 2003.

  1. "Svt" <> wrote in news:6de501c343fd$6319adc0$:

    > Hello,
    > I am creating web service to save file document and I
    > need to specify <file path>. What is the correct syntax
    > for it?
    > It should be:
    > string sFile = "<file path>";
    > I tried:
    > string sFile = "C:\MyDocuments\test_app.txt\";
    > and I get an error: Unrecognized escape sequence.


    A single backslash in a C# string is interpreted as an escape
    sequence:

    http://msdn.microsoft.com/library/en-
    us/csspec/html/vclrfcsharpspec_2_4_4_5.asp

    If you want C# to treat the backslash character as a literal, either
    double up the backslash:

    string sFile = "C:\\MyDocuments\\test_app.txt\\";

    or prepend the string with the @ character:

    string sFile = @"C:\MyDocuments\test_app.txt\";


    Hope this helps.

    Chris.
    -------------
    C.R. Timmons Consulting, Inc.
    http://www.crtimmonsinc.com/
     
    Chris R. Timmons, Jul 7, 2003
    #1
    1. Advertisements

  2. Chris R. Timmons

    NonStopMark

    Joined:
    Jan 2, 2007
    Messages:
    1
    Likes Received:
    0
    Location:
    Bolton, UK
    Progressing into C# & ASP.NET 2.0

    Hi,

    This reply has helped me in 2007. I am currently trying to learn C# and ASP.NET 2.0 and this was the first problem I had in 2007. Thanks for the reply.

    Cheers

    MARK
     
    Last edited: Aug 17, 2009
    NonStopMark, Jan 2, 2007
    #2
    1. Advertisements

  3. Chris R. Timmons

    Madhan Babu

    Joined:
    Dec 12, 2011
    Messages:
    1
    Likes Received:
    0
    thank you C.R. Timmons it worked...
     
    Madhan Babu, Dec 12, 2011
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Evgeny Zoldin

    How to convert HTML escape-sequence into String?

    Evgeny Zoldin, Nov 16, 2003, in forum: Microsoft Dot NET
    Replies:
    1
    Views:
    272
    Erik Frey
    Nov 16, 2003
  2. Sepham.com
    Replies:
    0
    Views:
    198
    Sepham.com
    Nov 22, 2004
  3. Guest
    Replies:
    1
    Views:
    620
    Cor Ligthert
    Jan 19, 2005
  4. Guest

    Regex Error - unrecognized escape sequence

    Guest, Mar 31, 2005, in forum: Microsoft Dot NET
    Replies:
    1
    Views:
    708
    Cor Ligthert
    Mar 31, 2005
  5. toddc612

    Unrecognized attribute 'requirePermission' error.

    toddc612, Nov 21, 2005, in forum: Microsoft Dot NET
    Replies:
    0
    Views:
    3,348
    toddc612
    Nov 21, 2005
Loading...

Share This Page