added try/catch for createDirectory and createFile methods