Best way to concatenate file directory and name into path

I need to create a full filepath by concatenating a directory with a filename that is coming through an event as a string. I’m currently doing some basic string appending for this, but it obviously isn’t cross-platform. Is there a way to do this where it will work on all platforms, or perhaps a way to ‘canonicalize’ the path?

If this were C++17 I’d be doing something like

std::filesystem::path p = directory / filename;

… which will use the correct format regardless of platform…

1 Like

Just do it:
image