Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Accessing Workspace Files
Accessing Workspace Files [message #444411] Wed, 15 February 2006 20:13 Go to next message
Eclipse UserFriend
I hope this is an easy question...

I am trying to access a file that is in the workspace (/data/myData.xml).
I have tried :
File f = new File(Platform.getLocation().toFile(),"/data/myData.xml");

But this points to the runtime directory. :(

And I have tried just using :
File f = new File("/data/myData.xml");

But that points to the workspace in eclipse. :(

Is there a way to access files like there is to access images :
AbstractUIPlugin.imageDescriptorFromPlugin("com.xyz.Test", "/icons/sm.gif");

Also is there an advantage to using IFile? I can't find much
documentation on the differences.

Thanks,
Jon
Re: Accessing Workspace Files [message #444529 is a reply to message #444411] Thu, 16 February 2006 16:03 Go to previous messageGo to next message
Eclipse UserFriend
You can use:
ResourcesPlugin.getWorkspace().getRoot().getProject("My Project");

Then you should have access to all files in your workspace. :-)

Regards,
Stefan

JB schrieb:
> I hope this is an easy question...
>
> I am trying to access a file that is in the workspace (/data/myData.xml).
> I have tried :
> File f = new File(Platform.getLocation().toFile(),"/data/myData.xml");
>
> But this points to the runtime directory. :(
>
> And I have tried just using :
> File f = new File("/data/myData.xml");
>
> But that points to the workspace in eclipse. :(
>
> Is there a way to access files like there is to access images :
> AbstractUIPlugin.imageDescriptorFromPlugin("com.xyz.Test", "/icons/sm.gif");
>
> Also is there an advantage to using IFile? I can't find much
> documentation on the differences.
>
> Thanks,
> Jon
>
Re: Accessing Workspace Files [message #444614 is a reply to message #444411] Fri, 17 February 2006 15:30 Go to previous message
Eclipse UserFriend
Originally posted by: jkilbour.pol.net

There's a way to do this also using
Platform.getBundle("String.name.of.plugin").getEntry("directory/file ");
this returns a URL which can be converted to an InputStream. This is from
the RCP book. So you can just make a folder in your project and access the
contents, without having to store the files in the bin directory.
Previous Topic:Run and Search menus in RCP
Next Topic:remote interface lookup issue(StatefulProxyFactory)
Goto Forum:
  


Current Time: Sat Nov 08 08:59:52 EST 2025

Powered by FUDForum. Page generated in 0.03277 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top