Languages
[Edit]
EN

C# / .NET - file exists

12 points
Created by:
Mohammad-Oneal
327

In C# / .NET it is possible to check does file exist in following way.

File.Exists method example

string path = @"C:\path\to\file.txt";

bool exists = File.Exists(path);
Console.WriteLine("File exists: " + (exists ? "Yes" : "No"));

Output:

File exists: No

References

  1. File.Exists Method - Microsoft Docs

Alternative titles

  1. C# / .NET - check if file exists
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

C# / .NET - file API

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join