简体   繁体   中英

Windows : Delete directories

org.eclipse.core.runtime.CoreException: Could not move: C:\gram\zmedia.
    at org.eclipse.core.internal.filesystem.Policy.error(Policy.java:55)
    at org.eclipse.core.filesystem.provider.FileStore.move(FileStore.java:415)
    at org.eclipse.core.internal.filesystem.local.LocalFile.move(LocalFile.java:352)
    at com.zmedia.zide.config.model.Service.updateDeploymentSetup(Service.java:923)
    at com.zmedia.zide.config.model.Service.update(Service.java:886)
    at com.zmedia.zide.util.ServiceAPI.create(ServiceAPI.java:239)
    at com.zmedia.zide.ui.wizards.pages.CreateServicePage$5.run(CreateServicePage.java:525)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: org.eclipse.core.runtime.CoreException: Problems encountered while deleting files.
    at org.eclipse.core.internal.filesystem.local.LocalFile.delete(LocalFile.java:125)
    at org.eclipse.core.filesystem.provider.FileStore.move(FileStore.java:411)
    ... 6 more

Hi All ,

We developed a plugin on top of eclipse . We gave a option for users to remove their old projects in eclipse .

Issue : If a file is opened on this directory or any process using their directory on delete operation will be the problem . This issue is specific for only windows users .

Is there any way to force delete a directory on windows?

How can I notify to users like this " This process is using our directory . Please close this process and proceed " .

Is there any way to know which process is accessing this?

您可以使用Unlocker ,它具有可移植的版本和命令行选项(取决于其许可证),您可以将其与插件一起发送并通过命令行使用它来解锁使用的文件。

Is there any way to force delete a directory on windows?

You can kill the process holding the lock or ask the user to close the process. Unfortunately this could be the eclipse process itself or explorer.

In a debug situation, to know which process is using a file, you could use the excellent Process Explorer as decribed here .

AFAIK, there is no simple way with the Java SDK to know which process is using it.

What you could do is mark the file as deleteOnExit() and it would be removed when the user actually quits Eclipse.

Probably its your own plugin that's locking the files. Try to implement a method/strategy to "release" them before attempting to delete. You can use Apache Commons IO to help you build/identifying this. Take a look at the FileDeleteStrategy . Also check the "FORCE" option.

I doubt that there is good way in Java alone to find out what process is keeping you from deleting the folder. Also that may be a little aggressive. Why not copy if you cannot move and present a dialog that lists the projects that could not be moved (or deleted) so that the user can take care of it by himself. There could be a reason a file was kept open after all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM