Fix bug when opening directory.