Why is this code dying on Windows?
I'm trying to port some code from Linux to Windows. I really don't know much about Windows, and so I'm kind of flying blind. The code in question attempts to delet开发者_运维百科e some directories using org.apache.commons.io.FileUtils
// If the mergesegs worked, delete the segment dirs
for (File file : segments.listFiles())
{
if (!file.equals(mergedSegFile))
{
LOG.debug("deleting segment dir " + file);
FileUtils.deleteDirectory(file);
}
}
segments
is a File, as is mergedSegFile
. It dies with an IOException "Unable to delete file: c:\www\tomcat\crawls\test\TestingCode.site\crawldir\segments\20101128194700\parse_test\part-00000\data"
.
These files were created by a previous run of the same program (which does some Nutch crawling). Doing an ls -l
under cygwin shows the user and group are correct, but the perms are 000.
Further info:
dir
doesn't tell me anything about permissions.- I can remove the directory with
del
on a cmd.exe window orrm -rf
on a cygwin bash window. - The files in question, and the directory they are in, were created earlier in the same run of the same program.
- The computer is running Windows 7, so I assume that means it's NTFS.
Plenty of possibilities here. The path itself doesn't look bad. Your best bet is to try to delete that directory manually from a command prompt and see what error you get.
Things to check:
- Is the directory, or any of its contents, in use by an application?
- Is the directory, or any of its files, read-only? (Check with
dir
, notls
). - Does the directory, or any of its files, have special permissions, and you are not an administrator?
- Btw, this is NTFS, I presume?
精彩评论