function chooseDir and readDir