Show the system's save-file dialog or open-file dialog.


ShowFileDialog(bSave, filter, filterIndex, defaultExtension, initialDir, allowMultiSelect, overwritePrompt, flags);


<bool> bsave : true -- show save-file dialog, false -- show open-file dialog.
<string> filter : the filter name specifies the filter pattern (for example, "JPG | *.jpg"). To specify multiple filter patterns, use a semicolon to separate the patterns (for example, "JPG, PNG and TIF | *.jpg;*.png;*.tif" or "JPG, PNG , TIF" for macOS). A pattern string can be a combination of valid file extensions with asterisk (*). To show all files, use the string "All Files | *.*".
<int> filterIndex : determines the index for the filter string we set, in other words, where the filter string should appear in the dialog's filters drop-down box. By default, it's 0 and you don't need to change it. This parameter doesn't work on macOS.
<string> defaultExtension : define the default extension which will be appended to the file name. Only useful when you try to save an image or images. If this member is NULL and the user fails to type an extension, no extension is appended.
<string> initialDir : the initial directory. The algorithm for selecting the initial directory varies on different platforms.
<bool> allowMultiSelect : true -- allow multiple selection, false -- only allow single file selection.
<bool> overwritePrompt : true -- if a file already exists with the same name, user needs to confirm before the existing file is overwritten, false -- if a file already exists with the same name, it will be overwritten without further user confirmation.
<int> flags : if this parameter equals 0, the program will be initiated with the custom settings. Otherwise it will be initiated with default flags, which means allowMultiSelect and overwritePrompt will not work.

Return value


true indicates success. false indicates failure.

When 'false' is, check ErrorCode or ErrorString for error information.


No matter it succeeded or failed, this method will trigger OnGetFilePath event. If more than one file are selected, the event will also be called multiple times.

See also



&amp;lt;div id="dwtcontrolContainer"&amp;gt&amp;lt;/div&amp;gt&nbsp;
&amp;lt;input type="button" value="Load" onclick="LoadImage();" /&amp;gt; 
Dynamsoft.WebTwainEnv.RegisterEvent('OnWebTwainReady', Dynamsoft_OnReady); 
var DWObject; 
function Dynamsoft_OnReady() { 
  DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer'); 
  if (DWObject) { 
    DWObject.RegisterEvent('OnGetFilePath', OnGetFilePath); 
function LoadImage() { 
  if (DWObject) { 
    DWObject.IfShowFileDialog = false; 
      DWObject.ShowFileDialog(false, "JPG,PNG,TIF| *.jpg;*.png;*.tif", 0, "", "", true, true, 0); 
     DWObject.ShowFileDialog(false, "JPG,PNG,TIF", 0, "", "", true, true, 0); 
function OnGetFilePath(bSave, filesCount, index, path, filename){ 
  if(bSave == false) { 
Is this page helpful?

Leave a Reply

Your email address will not be published.