Answers for "check if file exist c#"

C#
16

c# check file exists

if (File.Exists(@"D:\myfile.txt")) {
   Console.WriteLine("The file exists.");
}
Posted by: Guest on February-03-2020
9

c# file exist

if (File.Exists("file.exe"))
{
	//file exist
} else {
  //does not exist
}
Posted by: Guest on March-02-2020
2

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!");
		}
	}
}
Posted by: Guest on November-13-2020
1

check if file exist c#

if(File.Exists(@"C:\file.exe"))
{
    Console.WriteLine("This file exists!");
}
else
{
  Console.WriteLine("This file does not exist!");
}
Posted by: Guest on September-29-2021
1

How to find out if a file exists in C# / .NET?

File.Exists(path)
Posted by: Guest on July-30-2021

C# Answers by Framework

Browse Popular Code Answers by Language