Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

Open file Browse

How can make Open dialog brows to select a file or directory ?
0
a_sameer
Asked:
a_sameer
  • 5
  • 3
1 Solution
 
msmolyakCommented:
What exactly you are trying to do? Is java.awt.FileDialog what you want?
0
 
a_sameerAuthor Commented:
That's ok , But how can write this code in HTML
and where can found the class of this function .

Thanks ,,,
0
 
msmolyakCommented:
The easiest thing to do is to use JavaScript. Alas, that would work only in Netscape Navigator 3.x and above.

<SCRIPT LANGUAGE="JavaScript">

var fileName;

/**
 * Display a file dialog and return a selected file.
 */
function getFile()
{
    var parentFrame = new java.awt.Frame();
    var fileDialog = new java.awt.FileDialog(parentFrame, "Select a file to print");
    fileDialog.setVisible(true);
    fileName = fileDialog.getDirectory() + fileDialog.getFile();
    alert("Selected file " + fileName);
}
</SCRIPT>

The necessary classes come with Netscape's Java support and you should not have to do anything to install these classes.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
a_sameerAuthor Commented:
ok , that's very good ... Thanks Msmolyak.

But I'm sorry ,, I want to select a Directory only (such as Empty Directory How can select it ?)



0
 
a_sameerAuthor Commented:
ok , that's very good ... Thanks Msmolyak.

But I'm sorry ,, I want to select a Directory only (such as Empty Directory How can select it ?)



0
 
msmolyakCommented:
I am afraid AWT does not posess this capability. It is possible, JavaScript has built-in functions to do that, I am not that familiar with JavaScript.  I will check what Swing has in that respect. I know Swing has a FileChooser but first of all it's in a preview stage, then I am not sure whether it can select directories and finally unlike AWT, Swing classes do not come with the browser so it will be harder to use them from JavaScript,
0
 
msmolyakCommented:
Swing;s FileChooset does not seem to support that either, which is only logical. It's hard to use the same interface for selecting both files and directories since double click ona file means "Select", whicl double click on a directory means "Expand". The oly place where I've seen directory selection dialogs is InstallShield when it asks you for the installation directory.
0
 
msmolyakCommented:
I'll take my last statement back. Swing's FileChooser does allow to choose directories only according to its description.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now