Only use the directory if it is valid.

Refs #10844