0

I am trying to remove a folder (and the single file that it contains) from my eclipse workspace but there does not seem to be an option to simply remove the file. The only option is to delete it. When I tried to delete it, I got the following error:

Cannot Delete Content For Read Only Resource

These are the only options I get on right-clicking the folder:

enter image description here

And these on right-clicking the file in it:

enter image description here

Note: This very similar question did not have an answer posted

rahs
  • 1,759
  • 2
  • 15
  • 31
  • Is it marked read only in the filesystem? If so, change it. – nitind Sep 04 '19 at 14:02
  • @nitind I don't want to change the permissions of the file. Isn't there a way to simply remove the file rather than deleting it? – rahs Sep 04 '19 at 14:13
  • Eclipse doesn't have any sort of remove that doesn't delete the file. You may be able to hide it from things like Project Explorer by setting filters in the view. – greg-449 Sep 04 '19 at 14:27
  • @greg-449 I see. So I can add a read-only file to my workspace but not remove it? – rahs Sep 04 '19 at 14:49
  • Eclipse considers every in the workspace folder structure to be part of the workspace. – greg-449 Sep 04 '19 at 16:06
  • @greg-449 I don't think I fully understand. If I can explicitly add a folder to the workspace, can't I remove it? – rahs Sep 04 '19 at 17:32
  • I really don't understand what you mean by remove. If you add a folder you can delete it or move it to somewhere that is not in the workspace. What you can't do is have it remain in the workspace but have Eclipse ignore it. – greg-449 Sep 04 '19 at 20:24
  • @greg-449 The way I add existing classes to the Eclipse workspace is by using the 'import' functionality. Let's say I import class A. Now I don't need class A to remain in the Eclipse workspace anymore - but I don't want to delete it from my computer either. Is there a way to tell eclipse to not look at that certain file anymore? – rahs Sep 04 '19 at 21:06

1 Answers1

0

Eclipse considers everything in the workspace folders to be part of the workspace. Deleting or moving to a location outside of the workspace is the only way to remove something completely from the workspace.

For source files you are no longer using you can move them to a folder outside of the project source path (I usually call this 'unused' or 'obsolete'). Eclipse does not compile source files like this.

You can also set filters in the Project Explorer and Package Explorer to not show files matching patterns.

greg-449
  • 109,219
  • 232
  • 102
  • 145