Do you want root url or root dir?
Given that you're putting this file into the root of your wordpress I assume its not a plugin or something like that.
Here is how to get the root url
<?php echo get_bloginfo('url'); ?>
Otherwise if you want the path (to include()
for instance) its perfectly reasonable to just do:
../../../file-in-root.php -> as many ../s as you need to go back directories
I do this all the time. If you think your directory structure may change a lot, you can just put the whole path to the file e.g.
/home/w/o/wordpress/web/public_html/file-in-root.php
If you're creating a plugin and you don't know the path to the file then obviously it would be different, but there are wordpress functions for that. However as you're using root I guess this is just for your own server/website configuration and this will be fine.