浏览文件从“我的电脑”路径

时间:2017-01-25 04:57:09

标签: java swt

我需要从路径浏览文件,即“我的电脑”。我没有将驱动器指定为“c”或“d”。

默认情况下,路径应指向“我的电脑”。

任何开放都可以帮助我。

我们正在使用SWT。

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.open();
DirectoryDialog dialog = new DirectoryDialog(shell);
dialog.setFilterPath(" "); //MyComputer
System.out.println("RESULT=" + dialog.open());
while (!shell.isDisposed()) {
    if (!display.readAndDispatch())
        display.sleep();
}
display.dispose();
}

1 个答案:

答案 0 :(得分:0)

以下将默认选择My Computer条目。

dialog.setFilterPath("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}");