Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Delete changed file
Delete changed file [message #453554] Wed, 02 August 2006 14:29
Eclipse UserFriend
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);
Previous Topic:Registry Editor In Rcp
Next Topic:Integration with GEF and RCP actions
Goto Forum:
  


Current Time: Thu Oct 10 04:57:26 GMT 2024

Powered by FUDForum. Page generated in 0.03001 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top