Get the public path directory I want to save file programmatically in public path, and I want to know how can I get Public Directory path in Drupal 8. In Drupal 7, I would use the following code.

drupal_realpath(file_default_scheme() . '://')


What is the equivalent in Drupal 8?
According to realpath API, you can Get it with :

\Drupal::service('file_system')-&gt;realpath(file_default_scheme() . "://");