Compiler: Visual C# 2005 Express

I am tring to see if a file exists and if it does delete it.

To see if the file exists I am using:
bool exists;
exists = Syste.IO.File.Exists(@"c:\test.txt");

To delete the file I am using:

The test file is located in c:\ and is called test.txt however, exists always returns false and the file is never deleted.

What am i doing wrong
What is the purpose of the @ symbol before the file name


Re: Visual C# General C# Newbie - Problem with syntax?

Christian Liensberger - MSP

The @ symbol just disables the escape codes in the following string. \t would be an escape code, but by putting the @ symbol in front of the string that escape code is disabled. From what I see your code should run fine... Are you sure the test.txt is not hidden or you have no rights to access the directory from your code

I tried this one and it's working great here!

            bool exists = System.IO.File.Exists(@"C:\Users\Chris\Downloads\JoostSetup-0.8.1.exe");