While I can't tell you precisely what is wrong, I may be able to tell you how to get an answer.
java.io.File is old and obsolete. It was part of Java 1.0, and many of its methods are unreliable for various reasons, often returning an uninformative magic value like 0 or null instead of throwing an exception that actually describes the nature of the failure.
The File class has been replaced with Path. You can obtain a Path instance with Paths.get or File.toPath.
Once you have a Path, most operations on it are performed with the Files class. In particular, you probably want either Files.exists or Files.isDirectory.
You may also want to consider deleting that directory yourself, using Files.walkFileTree, so if it fails, you'll get a useful and informative exception:
Path gwxFolder = Paths.get("C:\\Windows\\System32\\GWX");
if (Files.exists(gwxFolder)) {
try {
Files.walkFileTree(gwxFolder, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file,
BasicFileAtttributes attributes)
throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir,
IOException e)
throws IOException {
if (e == null) {
Files.delete(dir);
}
return super.postVisitDirectory(dir, e);
}
});
} catch (IOException e) {
StringWriter stackTrace = new StringWriter();
e.printStackTrace(new PrintWriter(stackTrace, true));
JOptionPane.showMessageDialog(null, stackTrace);
}
}