You can get the Magento 2 base directory the same way as in Magento 1.x: it is stored in the constant BP.
BP
See also other filesystem topics: