Languages
[Edit]
EN

C# / .NET - file exists

12 points
Created by:
AnnLen
1771

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
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.