Hi,
(background)
I'm using Java.io.File
to do some windows directory searching. Basically the user inputs a directory path and I validate the path with file.isDirectory()
. If the path is invalid I ask the user to re-enter a correct path. Once I get a valid directory I proceed with other File operations.
(problem)
Now the problem occurs when the user enters the root directory. For example, e:
. In this case file.list()
provides the following output [.classpath, .project, .settings, bin, src]
.
As you can see this does not include any folders.
However if he enters e:\
then file.list()
fetches the existing directories also [$RECYCLE.BIN, <some directories>, <some files>, RECYCLER, System Volume Information]
This time we don't have classpath, project etc. yet both e:
and e:\
are considered valid directories.
1) Can someone explain this strange behavior?
2) Also, to avoid this problem is there a better method than adding a dirty manual check for x:
and converting it into x:\
?