Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » some problem in getting a file from Project or some Folder
some problem in getting a file from Project or some Folder [message #45453] Fri, 23 May 2003 13:04 Go to next message
jelda is currently offline jeldaFriend
Messages: 42
Registered: July 2009
Member
Hi,
I have some simple problem.Hope I am doing something wrong.
I can not get a resource( file ) from a Project.
Here is what I am doing:
-I have project "test".in that I have a folder "test" in whihc I have
test.txt.
-I opened the project
-And want to open the file in that. But i can not do it. Always I am getting
exception."file does not exists"..Please help me.

here is the sample code that I am doing.//ofcourse its just a test
Please see my comments as java comments in the sample code.
IWorkspace workspace = ResourcesPlugin.getWorkspace();

IWorkspaceRoot root = workspace.getRoot(); //

IProject[] ps = root.getProjects();

String str = ps[0].getName();//Just for test.


IProject myWebProject = root.getProject(str);//My test does not work. Here I
get always only one project Desktop.//so using this Desktop project only for
doing test

// I copied my text.txt in Desktop project(For doing test.)

boolean pExists =myWebProject.exists();boolean isOpen =
myWebProject.isOpen();

if ( pExists && !isOpen)

myWebProject.open(null);

IFolder folder = myWebProject.getFolder("test");


IFile file= folder.getFile("tst.txt");

boolean fileExists = file.exists();//always returns false..

I tried somany cases but none is working.Please help me.I am doing something
wrong.But I couldn't figure it out.

Ramana
Re: some problem in getting a file from Project or some Folder [message #46192 is a reply to message #45453] Fri, 23 May 2003 15:46 Go to previous messageGo to next message
Balaji  is currently offline Balaji Friend
Messages: 101
Registered: July 2009
Senior Member
1. Have u copied the folder and file under ur desktop project.
2. The file name specified is tst.txt.. .Do u have test.txt / tst.txt.

IProject project = workspace.getRoot().getProject("Test");
IFolder folder = project.getFolder("test");
IFile file = folder.getFile("test.txt");

HTH
~B

"jelda" <j_jvr@yahoo.com> wrote in message
news:bal69e$il4$1@rogue.oti.com...
> Hi,
> I have some simple problem.Hope I am doing something wrong.
> I can not get a resource( file ) from a Project.
> Here is what I am doing:
> -I have project "test".in that I have a folder "test" in whihc I have
> test.txt.
> -I opened the project
> -And want to open the file in that. But i can not do it. Always I am
getting
> exception."file does not exists"..Please help me.
>
> here is the sample code that I am doing.//ofcourse its just a test
> Please see my comments as java comments in the sample code.
> IWorkspace workspace = ResourcesPlugin.getWorkspace();
>
> IWorkspaceRoot root = workspace.getRoot(); //
>
> IProject[] ps = root.getProjects();
>
> String str = ps[0].getName();//Just for test.
>
>
> IProject myWebProject = root.getProject(str);//My test does not work. Here
I
> get always only one project Desktop.//so using this Desktop project only
for
> doing test
>
> // I copied my text.txt in Desktop project(For doing test.)
>
> boolean pExists =myWebProject.exists();boolean isOpen =
> myWebProject.isOpen();
>
> if ( pExists && !isOpen)
>
> myWebProject.open(null);
>
> IFolder folder = myWebProject.getFolder("test");
>
>
> IFile file= folder.getFile("tst.txt");
>
> boolean fileExists = file.exists();//always returns false..
>
> I tried somany cases but none is working.Please help me.I am doing
something
> wrong.But I couldn't figure it out.
>
> Ramana
>
>
>
Re: some problem in getting a file from Project or some Folder [message #47797 is a reply to message #46192] Mon, 26 May 2003 08:37 Go to previous message
jelda is currently offline jeldaFriend
Messages: 42
Registered: July 2009
Member
It is tst.txt.
While typing it to forum. I did small mistake.
So its not question of file names. Its the question of how to program it.

I checked the file name and path. its no dobut that I wrote correctly in my
program.
I did tests with so many other files also..

I personally writing a plugin for eclipse. I wrote this code in plugin
implementaion. is this could be wrong?

Thanks in advance,
Ramana

"Balaji" <balajik@us.ibm.com> schrieb im Newsbeitrag
news:balfre$s2h$1@rogue.oti.com...
> 1. Have u copied the folder and file under ur desktop project.
> 2. The file name specified is tst.txt.. .Do u have test.txt / tst.txt.
>
> IProject project = workspace.getRoot().getProject("Test");
> IFolder folder = project.getFolder("test");
> IFile file = folder.getFile("test.txt");
>
> HTH
> ~B
>
> "jelda" <j_jvr@yahoo.com> wrote in message
> news:bal69e$il4$1@rogue.oti.com...
> > Hi,
> > I have some simple problem.Hope I am doing something wrong.
> > I can not get a resource( file ) from a Project.
> > Here is what I am doing:
> > -I have project "test".in that I have a folder "test" in whihc I have
> > test.txt.
> > -I opened the project
> > -And want to open the file in that. But i can not do it. Always I am
> getting
> > exception."file does not exists"..Please help me.
> >
> > here is the sample code that I am doing.//ofcourse its just a test
> > Please see my comments as java comments in the sample code.
> > IWorkspace workspace = ResourcesPlugin.getWorkspace();
> >
> > IWorkspaceRoot root = workspace.getRoot(); //
> >
> > IProject[] ps = root.getProjects();
> >
> > String str = ps[0].getName();//Just for test.
> >
> >
> > IProject myWebProject = root.getProject(str);//My test does not work.
Here
> I
> > get always only one project Desktop.//so using this Desktop project only
> for
> > doing test
> >
> > // I copied my text.txt in Desktop project(For doing test.)
> >
> > boolean pExists =myWebProject.exists();boolean isOpen =
> > myWebProject.isOpen();
> >
> > if ( pExists && !isOpen)
> >
> > myWebProject.open(null);
> >
> > IFolder folder = myWebProject.getFolder("test");
> >
> >
> > IFile file= folder.getFile("tst.txt");
> >
> > boolean fileExists = file.exists();//always returns false..
> >
> > I tried somany cases but none is working.Please help me.I am doing
> something
> > wrong.But I couldn't figure it out.
> >
> > Ramana
> >
> >
> >
>
>
Previous Topic:[ANN] Eclipse key bindings (pdf,doc) emacs/standard
Next Topic:[CVS] modify multiple branches
Goto Forum:
  


Current Time: Mon Dec 30 16:43:40 GMT 2024

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

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

Back to the top