How to Check file is exists or not at specific location programmatically in Magento 2?

You can check any physical file is exist or not at a specific location in Magento directory by Magento\Framework\Filesystem\Driver\File class.

You can use Magento 2 native class to check file is exist or not instead of the core PHP method.

I have taken a Block file and create a function for check file is exist or not via constructor DI,

Call from a template file,

echo $block->checkFileExists();

You need to pass file path in the above function to check file is available or not.

I have passed the filename as system.log from var folder. You can add any file name you want to check for file exists or not.