Answers for "check file exsist c#"

C#
10

c# file exist

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

c# check if file hast content

public static bool IsTextFileEmpty(string fileName)
{
    var info = new FileInfo(fileName);
    if (info.Length == 0)
        return true;

    // only if your use case can involve files with 1 or a few bytes of content.
    if (info.Length < 6)
    {
        var content = File.ReadAllText(fileName);   
        return content.Length == 0;
    }
    return false;
}
Posted by: Guest on April-14-2021

C# Answers by Framework

Browse Popular Code Answers by Language