tags:

views:

1882

answers:

3

I would like to test a string containing a path to a file for existence of that file (something like the -e test in Perl or the os.path.exists() in Python) in C#.

+12  A: 

Use:

File.Exists(path)

MSDN: http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx

Edit: In System.IO

Daniel Jennings
+5  A: 

System.IO.File.Exists(path)

msdn

pirho
+5  A: 

System.IO

using System.IO;
if (File.Exists(path)) 
                {
                    Console.WriteLine("file exists");
                }
Peter Hoffmann