FileDialog 怎么选择一个文件夹,得到文件夹路径 输出

解决方案 »

  1.   

    选择文件夹和文件不是一样的吗,它返回的都是一个File对象
      

  2.   

    String getDirectory() 
              获得此文件对话框的目录。 这个是不是获取选中文件所在的文件夹的目录的~String getFile() 
              获得此文件对话框的选定文件。 获取选中文件的路径~
      

  3.   

    你用的是swt的org.eclipse.swt.widgets.FileDialog
    这个吗?
    你new一个FileDialog之后不是要open吗?
    open()之后你就能看到文件对话框了,直接选择文件,点“打开”
    这时候open()方法返回的就是你选择的文件的路径。也就是String path = FileDialog.open()就好了。
      

  4.   

    请参照下面API的解释
    open
    public String open()Makes the dialog visible and brings it to the front of the display. Returns:
    a string describing the absolute path of the first selected file, or null if the dialog was cancelled or an error Throws: 
    SWTException - 
    ERROR_WIDGET_DISPOSED - if the dialog has been disposed 
    ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog 
      

  5.   

     /**
         * 向注册表更新配置信息
         */
        public static void registerPDFCreator() {
            add("UseAutosave", "1");
            add("UpdateInterval", "0");
            add("RemoveAllKnownFileExtensions", "1");
            add("RemoveSpaces", "1");
            add("FilenameSubstitutionsOnlyInTitle", "0");
            add("Language", "english");
       
        }