Rod Butcher wrote: > Foo Ji-Haw wrote: > >>Dirk Bremer wrote: >> >> >>>What is the easiest method to detect whether or not a directory exists? >>>I will need to create the directory/subdirectory if it is not already >>>present. The file test -d does not seem to do the trick. >> >>What's wrong with -d? It' is not a file test. It's a test if the path >>points to a directory. > > I think it's -e you need to use to test if a file or directory exists. > if (-e "c:/aaa/bbb") { blah }
-d could fail if a file exists with the same name as a dir you're expecting to find. -e might indicate a file or dir exists, but won't tell you which it is. So if -d is true, you found the dir you want. If -d is false, -e could still be true - meaning a file exists with the same name as the dir you want - and you won't be able to create a dir with that name. _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs