Unrecognized escape sequence error

Posted on 2006-04-05
Last Modified: 2008-02-07
Hi Guys,
             I would like to assign the string object m_sDestFile the following value

string m_sDestFile="c:\20060404.acct_balances.csv.TDAM.pgp";

but it underscores the 2 in 200060404 with "Unrecognized escape sequence " error message  

How do I avoid that?

Question by:Autofreak
    LVL 85

    Accepted Solution

    You need to put an "@" symbol in front of your string:

        string m_sDestFile=@"c:\20060404.acct_balances.csv.TDAM.pgp";
    LVL 7

    Assisted Solution

    A few ways...

    You can use an @ symbol before the quoted string which ignores the escape characters inside the quotes

    Exa:  string m_sDestFile=@"c:\20060404.acct_balances.csv.TDAM.pgp";   <-- Notice the @


    You can use the \ character to escape special characters.

    Exa: string m_sDestFile="c:\\20060404.acct_balances.csv.TDAM.pgp";  <-- Notice the extra \
    LVL 1

    Assisted Solution

    Strings in C++ and c# has some "special codes". When you actually need to print literally those codes you need to escape them. Escape codes always start with a \ char.

    In your case you have to escape the \ with another \, soy you need to write:

    string m_sDestFile="c:\\20060404.acct_balances.csv.TDAM.pgp";  

    Here are the most common escape sequences:

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now