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# 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!");
}
}
}
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