[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.cdt] Re: Adding new files to project.

How are you creating the file? To create a file you need to use IFile#create().

--
Derek


oren barzilai wrote:
That's exactly what I did, and it's working but only after I restart the eclipse.
I am working with eclipse 3.2.2 and cdt 3.1.2.2. any idea what wrong?


Thanks

Oren

"Derek Morris" <dmsubs@xxxxxxxxxxxxxxxxxxxx> wrote in message news:f15g0s$2i5$1@xxxxxxxxxxxxxxxxxxxx
How are you adding the files? You need to use an IFile to create project resource (rather than just using a File).

One way to obtain an IFile given a projectName and fileName within the project is:

public IFile getProjectFile(String projectName, String fileName) {
IFile file = null;
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(new Path(projectName));
if ((resource != null)
&& (resource.exists() && (resource instanceof IContainer))) {
IContainer container = (IContainer) resource;
file = container.getFile(new Path(fileName));
}
return file ;
}

HTH

--
Derek


oren barzilai wrote:
Hello,

I have defined new project type and by the operation class I have added new files to my project on creation, but for some reason I can see those files only after I restart the eclipse.
I have tried to call "refreshLocal" after adding the files with no result.


What am I doing wrong?

thanks

Oren Barzilai