问题描述
我需要一个项目文件夹的绝对位置,所以我尝试了
I need the absolute location of a project folder, so I tried
project.getRawLocation()
但这会返回 null
(至少在我使用 Import ... Existing projects into workspace 手动导入项目的情况下,我已经检查了 将项目复制到工作区复选框).
but this returns null
(at least in my case in which I have imported the project manually using Import ... Existing projects into workspace and I have checked the Copy projects into workspace checkbox).
事情是这样的
project.getParent().getRawLocation()
返回正确的 /work/Projekte/runtime-MyProduct.product
和
project.members()[0].getRawLocation()
返回 /work/Projekte/runtime-MyProduct.product/Test/.cproject
这也是正确的.
returns /work/Projekte/runtime-MyProduct.product/Test/.cproject
which is correct as well.
因此,我希望如此
project.getRawLocation()
会返回 /work/Projekte/runtime-MyProduct.product/Test
,但它会返回 null
.
would return /work/Projekte/runtime-MyProduct.product/Test
, but it returns null
.
谁能解释和/或告诉我哪里错了?
Can anyone explain and/or show me where I'm wrong?
推荐答案
getRawLocation()
说
如果此资源是现有项目,则返回的路径将为等于项目描述中的位置路径.
If this resource is an existing project, the returned path will be equal to the location path in the project description.
以及项目描述的 JavaDoc IProjectDescription.getLocation()
说:
and the JavaDoc for the project description IProjectDescription.getLocation()
says:
如果应该使用默认位置,则返回null
null is returned if the default location should be used
getLocation()
调用会返回一个路径.
The getLocation()
call will return a path.
这篇关于为什么 IResource.getRawLocation() 为 IProject 返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!