Is there an equivalent of “Add existing file” (to project) in Eclipse?

前端 未结 8 2059
情深已故
情深已故 2020-12-24 04:51

I am trying to map my Visual Studio experience onto Eclipse. Right now, I wish to add a file existing somewhere on the file system into a project in Eclipse. I expect it to

相关标签:
8条回答
  • 2020-12-24 05:19

    It turns out that just simply dragging the files into the src folder would work!

    0 讨论(0)
  • 2020-12-24 05:21

    In my case, I had to:

    1. right-click the project's name
    2. choose "Close Project"
    3. right-click the (now closed) project's name again
    4. choose "Open Project"

    Refreshing didn't work for me. :(

    Hopefully this helps someone else...

    0 讨论(0)
  • 2020-12-24 05:25

    I am a newbie to Eclipse Luna (the 64 bit latest version on Windows 7) but this worked for me:

    1. Copy the preexisting source files you which add to your project.
    2. In Project Explorer, right click your project and select New > File
    3. In the "New File" dialog box, your project's name / folder should be displayed as the parent folder for your new (existing) source file.
    4. Click on the "Advanced" button at the bottom of the "New File" dialog box.
    5. Check the "Link to file in the file system" checkbox.
    6. Click the "Browse" and browse to your preexisting source.
    7. Click the "Finish" button at the bottom of the dialog box.
    0 讨论(0)
  • 2020-12-24 05:29

    File->Import->General->File System should do it. There you can select the file(s) from some file system folder to your project (into folder).

    0 讨论(0)
  • 2020-12-24 05:29

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

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

    I had a file in a directory where a bunch of code files were and some of the files in that 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 simply selected the folder in my project and pressed 'F5' or right-clicked and selected 'refresh' and the files appeared in my project. It looks like that is the intended way of doing this.

    0 讨论(0)
  • 2020-12-24 05:31

    I just got this to work. YMMV

    I don't suppose it has to be there, but I put my file, xyz.cpp, into my project's source directory. My project has a source subdir named src, as in ProjName/src.

    Right Click on project name (my project was open and the only one open). NEW->FILE. Put in the filename, 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. It now has its contents.

    0 讨论(0)
提交回复
热议问题