Return error value from Stat.
Updated SetWorkingDirectory to check that path is a directory.