Why an @ in file path?

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I have seen some examples where an @ is used before a path statement:

docNav = new XPathDocument(@"c:\books.xml");

What is it for?

I have never used it for my file paths.

Thanks,

Tom
 
tshad said:
I have seen some examples where an @ is used before a path statement:

docNav = new XPathDocument(@"c:\books.xml");

What is it for?

I have never used it for my file paths.

Thanks,

The @ is an ESC sequence to tell the compiler that the "\" is there in the
path. Otherwise, you have to do C:\\books.xml.
 
----- Original Message -----
From: "tshad" <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Saturday, January 05, 2008 10:38 PM
Subject: Why an @ in file path?

I have seen some examples where an @ is used before a path statement:

docNav = new XPathDocument(@"c:\books.xml");

What is it for?

I have never used it for my file paths.

Thanks,

Tom


The @ means "use the following string verbatim". In a short file path like
your example it wouldn't be worth it, but it can save you a lot of typing of
escape sequences (and the confusion that can result) for very long paths.

Todd
 
Todd Carnes said:
----- Original Message -----
From: "tshad" <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Saturday, January 05, 2008 10:38 PM
Subject: Why an @ in file path?




The @ means "use the following string verbatim". In a short file path like
your example it wouldn't be worth it, but it can save you a lot of typing
of escape sequences (and the confusion that can result) for very long
paths.

Makes sense,

Thanks,

Tom
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

XPathDocument problem 2
I can't get the value of an attribute in an xml file 2
XSLT 1
XMLTextReader.Name always returns "" 4
Getting single treeview node by path 2
Xpath c# 1
Get Path of file 5
Path 4

Back
Top