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

[{'answer_id': 38962, 'author': 'Daniel Jennings', 'author_id': 3641, 'author_profile': 'https://Stackoverflow.com/users/3641', 'pm_score': 9, 'selected': True, 'text': '<p>Use:</p>\n\n<pre><code>File.Exists(path)\n</code></pre>\n\n<p>MSDN: <a href="http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx</a></p>\n\n<p>Edit: In System.IO</p>\n'}, {'answer_id': 38967, 'author': 'pirho', 'author_id': 3911, 'author_profile': 'https://Stackoverflow.com/users/3911', 'pm_score': 5, 'selected': False, 'text': '<p>System.IO.File.Exists(path)</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx" rel="noreferrer">msdn</a></p>\n'}, {'answer_id': 38971, 'author': 'Peter Hoffmann', 'author_id': 720, 'author_profile': 'https://Stackoverflow.com/users/720', 'pm_score': 6, 'selected': False, 'text': '<p><a href="http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx" rel="noreferrer">System.IO.File</a>:</p>\n\n<pre><code>using System.IO;\n\nif (File.Exists(path)) \n{\n    Console.WriteLine("file exists");\n} \n</code></pre>\n'}, {'answer_id': 22280061, 'author': 'shivi', 'author_id': 2412200, 'author_profile': 'https://Stackoverflow.com/users/2412200', 'pm_score': 3, 'selected': False, 'text': '<p>Give full path as input. Avoid relative paths.</p>\n\n<pre><code> return File.Exists(FinalPath);\n</code></pre>\n'}, {'answer_id': 65721211, 'author': 'Jesus Hedo', 'author_id': 10952876, 'author_profile': 'https://Stackoverflow.com/users/10952876', 'pm_score': 1, 'selected': False, 'text': '<p>I use WinForms and my way to use File.Exists(string path) is the next one:</p>\n<pre><code>public bool FileExists(string fileName)\n{\n    var workingDirectory = Environment.CurrentDirectory;\n    var file = $&quot;{workingDirectory}\\{fileName}&quot;;\n    return File.Exists(file);\n}\n</code></pre>\n<p>fileName <strong>must</strong> include the extension like <code>myfile.txt</code></p>\n'}]
['https://Stackoverflow.com/questions/38960', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2260/']