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 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;
}
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