Updated to throw exception for a null path as suggested.