Due to a bug in .NET Core, it will sometimes return a trailing null character in the paths. Since null characters are not allowed on any OS, this PR ensures that null characters are removed before returning the path string. This fixes #6500