I have a simple question that I can't find a answer to:

With the .NET Framework what is the difference in saying "folder1/folder2/file" and "folder1\\folder2\\file" in a file directory? Is there even a difference?

Also what does the "@" character do? I'm not sure if this is XNA specific or .NET specific but here is an example: ContentManager.Load<Texture2D>(@"SpriteSheets/Tile");


  • 3
    \$\begingroup\$ AFAIk, @"S:\ome\path\file.ext" will turn the string into "S:\\ome\\path\\file.ext" for you, so you don't have to escape it yourself. \$\endgroup\$ – user13213 Sep 16 '12 at 3:31

Here is a resource on what @""-style string literals are.

Basically they turn off escaping. So, for example, you only need @"\", instead of "\\" to get the \ character.

Another example: @"\t" gives you \t, whereas "\t" (no at symbol) gives you a tab character.

Internally XNA handles the difference between path separator characters. You can use \ or / (or some crazy combination of both) and it won't matter.

(I'm pretty sure Windows itself doesn't care which character you use either.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.