c# check file exists
if (File.Exists(@"D:\myfile.txt")) {
Console.WriteLine("The file exists.");
}
c# check file exists
if (File.Exists(@"D:\myfile.txt")) {
Console.WriteLine("The file exists.");
}
c# file exist
if (File.Exists("file.exe"))
{
//file exist
} else {
//does not exist
}
c# check if a file exists in a folder
using System;
using System.IO;
public class Example
{
public static void Main()
{
string path = @"C:\path\to\some\dir";
string filename = "somefile.ext";
if (File.Exists(path + @"\" + filename))
{
Console.WriteLine("File found in the specified directory!");
}
else
{
Console.WriteLine("File does not exist in the specified directory!");
}
}
}
check if file exist c#
if(File.Exists(@"C:\file.exe"))
{
Console.WriteLine("This file exists!");
}
else
{
Console.WriteLine("This file does not exist!");
}
How to find out if a file exists in C# / .NET?
File.Exists(path)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us