Help : Whats the "@" in the directory info call.

K

Krish

public static void Main()
{
try
{
DirectoryInfo di = new DirectoryInfo(@"c:\");

// Get only subdirectories that contain the letter "p."
DirectoryInfo[] dirs = di.GetDirectories("*p*");

Console.WriteLine("Number of directories with a p: {0}",
dirs.Length);

// Count all the files in each subdirectory that contain
the letter "e."
foreach (DirectoryInfo diNext in dirs)
{
Console.WriteLine("The number of files in {0} with an
e is {1}", diNext,
diNext.GetFiles("*e*").Length);
}
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}",
e.ToString());
}
}
 
M

Marina

It just means that the following string is a literal, so that characters
like '\' aren't treated as escape characters, but as what they are.
 
J

Jon Skeet [C# MVP]

Marina said:
It just means that the following string is a literal, so that characters
like '\' aren't treated as escape characters, but as what they are.

Slight correction there - it means it's a *verbatim* string literal.
Anything like "hello" is a literal.

A Google search for "verbatim string literal" provides more
information.
 

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

Top