Magento2 – How to get Directory of a Module


Here is the code how to load your module directory:
...
private \Magento\Framework\Module\Dir\Reader $dir;
public function __construct(\Magento\Framework\Module\Dir\Reader $dir)
{
$this->dir = $dir;
}
...
echo "Directory : ".$this->dir->getModuleDir('', 'Knowthemage_Hello');
...






