插件开发取路径问题

1.得到runtime workspace目录的绝对路径

 String file = Platform.getInstanceLocation().getURL().getPath();

2.得到runtime workspace目录下所有的工程

IWorkspace workspace = ResourcesPlugin.getWorkspace();
   IWorkspaceRoot root = workspace.getRoot();
   IProject[] newProjectHandle = root.getProjects();

 

for (int i = 0, size = newProjectHandle.length; i < size; i++) {
    IProject iProject = newProjectHandle[i];
    // 工程名字

String projectName = iProject.getName();

IResource[] resources = iProject.members();
    for (int j = 0, n = resources.length; j < n; j++) {
     if (resources[j].getType() == IResource.FILE
       && resources[j].getFileExtension().equals("xpdl")) {
      // 包:工程下xpdl文件的绝对路径,包路径
      String xpdlFileFullPath = resources[j].getLocation()
        .toOSString();

}}

你可能感兴趣的:(J#)