Is there an equivalent to "Add an Existing File" (for a project) in Eclipse?

I am trying to match the experience of Visual Studio on Eclipse. Right now I want to add a file that exists somewhere in the file system to a project in Eclipse. I expect it to be copied to the original project folder.

Currently, I see only one way - switch to Windows Explorer (in my case, a full commander) and copy the file yourself, then update the project.

Is it possible to do the same without leaving the Eclipse environment?

Thank.

+47
eclipse
Nov 24 2018-11-11T00:
source share
8 answers

File->Import->General->File System should do this. There you can select a file from any folder of the file system in your project ( into folder ).

+37
Nov 24 '11 at 8:12
source share

I had the same problem, but I found another solution.

Let me state my problem so that we are sure that we are talking about the same thing.

I had a file in a directory where there were a bunch of code files, and some of the files in this directory were shown as "in my project", and some of the files were missing. I wanted the missing files to appear in my project.

I just selected a folder in my project and pressed β€œF5” or right-clicked and chose β€œrefresh” and the files appeared in my project. This seems like the intended way to do this.

+54
Feb 27 '14 at
source share

Even easier. Just drag and drop the file from Explorer to the correct package in Eclipse. He will ask you if you want to copy or link the file (s).

+8
Jun 25 '13 at 1:54 on
source share

I'm new to Eclipse Luna (64-bit on Windows 7), but this worked for me:

  • Copy the existing source files that you add to your project.
  • In Project Explorer, right-click the project and select New> File
  • In the New File dialog box , the name / folder of the project should appear as the parent folder for your new (existing) source file.
  • Click the Advanced button at the bottom of the New File dialog box.
  • Check the box next to "Link to file on file system .
  • Click Browse and browse to the original source code.
  • Click the Finish button at the bottom of the dialog box.
+4
Apr 16 '15 at 23:47
source share

In my case, I had to:

  • right click project name
  • select " Close Project "
  • right click project name (now closed)
  • select " Open Project "

Refreshment did not help me. :(

Hope this helps someone else ...

+2
Jan 20 '15 at 2:36
source share

I just got it to work. Ymmv

I don't think it should be there, but I put my xyz.cpp file in the project's source directory. My project has an original subdisk named src, as in ProjName / src.

Right-click on the project name (my project was open and only one was open). New-> FILE. Enter the file name xyz.cpp. Click OK or press Enter.

The file will open in the editor and complain that it is empty. Close it WITHOUT SAVING.

Reopen the file. Now it has its content.

0
Apr 18 '13 at 13:57 on
source share

It turns out that just dragging and dropping files into the src folder will work!

0
Mar 30 '15 at 3:38
source share

Just found a quick way to add files:

  • Copy the file to your project directory using the file browser.

  • In the Eclipse project browser, select your project.

  • Press [right mouse button] β†’ Update (or press F5 on a Windows computer).

Voila

(worked on Neon-4.6.2)

0
Feb 17 '17 at 20:17
source share



All Articles