Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-team-dev] IFile.exists() always returns false

From my plugin code I have created a new file in my workspace and am adding it to my project using the following code:

 

                    IPath workspaceIPath = new Path(absolutePathToFile);

                    IFile toFile = toContainer.getFile(workspaceIPath);

 

I don’t bother calling toFile.create() since the file is already there, plus from the navigator I see my new file in the project.  All looks good so far.

 

The problem is I want to set a property value on the file as soon as I add it to the workspace.  I’m using the following updated code

 

                    IPath workspaceIPath = new Path(absolutePathToFile);

                    IFile toFile = toContainer.getFile(workspaceIPath);

                    toFile.refreshLocal(IResource.DEPTH_INFINITE, null);

                    if (toFile.exists())

                        toFile.setPersistentProperty(MY_KEY,  “Some string”);

 

toFile.exists() always returns false.  I thought refreshLocal() would take care of it, but it doesn’t.  I’ve tried a bunch of things and have searched through the bug list and mailing lists.  I haven’t come up with anything.  Any thoughts?

 

Regards,

Don

 

 

 

 

 


Back to the top