The isDir() function is used to check a given file is a directory or not.
Use ifile. open(): ifile. open() is mainly used to check if a file exists in the specific directory or not.
While checking if a file exists, the most commonly used file operators are -e and -f. The '-e' option is used to check whether a file exists regardless of the type, while the '-f' option is used to return true value only if the file is a regular file (not a directory or a device).
Use:
File.Exists(path)
MSDN: http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx
Edit: In System.IO
System.IO.File:
using System.IO;
if (File.Exists(path))
{
Console.WriteLine("file exists");
}
System.IO.File.Exists(path)
msdn
Give full path as input. Avoid relative paths.
return File.Exists(FinalPath);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With