PC Review


Reply
Thread Tools Rating: Thread Rating: 16 votes, 3.81 average.

Re: Error in c# project: Unrecognized escape sequence

 
 
Chris R. Timmons
Guest
Posts: n/a
 
      7th Jul 2003
"Svt" <(E-Mail Removed)> wrote in news:6de501c343fd$6319adc0$(E-Mail Removed):

> 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/
 
Reply With Quote
 
 
 
 
New Member
Join Date: Jan 2007
Location: Bolton, UK
Posts: 1
 
      2nd Jan 2007
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 by NonStopMark; 17th Aug 2009 at 09:16 AM..
 
Reply With Quote
 
 
 
 
New Member
Join Date: Dec 2011
Posts: 1
 
      12th Dec 2011
thank you C.R. Timmons it worked...
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RegEx and Vb.net /// "Unrecognized escape sequence" sloan Microsoft VB .NET 6 27th Mar 2007 06:12 PM
Unrecognized escape sequence Jeff Microsoft ASP .NET 1 1st Jul 2006 04:07 AM
unrecognized escape sequence Abraham Luna Microsoft C# .NET 4 8th Sep 2005 06:44 PM
Regex Error - unrecognized escape sequence =?Utf-8?B?UEs5?= Microsoft Dot NET 1 31st Mar 2005 08:13 AM
Unrecognized escape sequence Christopher Ireland Microsoft C# .NET 2 20th Sep 2004 07:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:35 PM.