Delete changed file [message #453554] |
Wed, 02 August 2006 14:29 |
Eclipse User |
|
|
|
Originally posted by: nagel.trium.de
Hi all,
Like shown below I create a file and open an editor, in which the file
contents are displayed. In the editor's dispose() I want to delete the
file (calling file.delete(true, null)), but it does not work, when the
contents have been changed. A ResourceException is thrown.
Have you any idea, how I can delete the file?
Thanks in advance,
Lars
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject("DummyProject");
IFolder folder = project.getFolder("DummyFolder");
IFile file = folder.getFile(name + ".xml");
if(!project.exists()) project.create(null);
if(!project.isOpen()) project.open(null);
if(!folder.exists()) folder.create(IResource.NONE, true, null);
if(!file.exists())
{
byte[] bytes = doc.getBytes();
InputStream source = new ByteArrayInputStream(bytes);
file.create(source, IResource.FORCE, null);
}
IFileEditorInput fei = new FileEditorInput(file);
IEditorPart ep = PlatformUI.getWorkbench().getActiveWorkbenchWindow().
getActivePage().openEditor(fei, XmlAuthor.ID);
|
|
|
Powered by
FUDForum. Page generated in 0.03001 seconds