C#/.NET: Check if a file exists
Question by CSchaf | 2014-09-05 at 19:38
How can I check whether a file exists on my hard drive or any other storage device using C# (C-Sharp, .NET Framerwork)?
I have a string containing the full file path and would like to check that. Is there anything like one of the FileExists-functions known from other programming languages? When trying to type this, the IDE cannot find such a function.
Related Topics
How to resize Image before Upload in Browser
Tutorial | 13 Comments
Lazarus: Load File as Byte Array and save Byte Array as File
Tutorial | 0 Comments
PHP: File Download Script
Tutorial | 0 Comments
Rename File to its Folder Name
Tutorial | 0 Comments
SQLite: Check whether Table exists
Info | 0 Comments
Website Performance: Deliver JavaScript and CSS files compressed to reduce loading times
Tutorial | 0 Comments
CSS: Include CSS Stylesheets in HTML
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
You can find the function, you are searching for, in the class "File" (System.IO) providing some file handling functions.
Here is a small example:
You can just pass a string with the file path to File.Exists and you get true or false as the return value depending on the file is existing or not.
2014-09-06 at 07:49