Using System.Windows.Forms.OpenFileDialog

The following example demonstrates

  • The use of the System.Windows.Forms.OpenFileDialog DotNetControl as alternative to the MAXScript GetOpenFileName..
  • The main advantage of the DotNet version is the ability to select multiple files at once.

Using System.Windows.Forms.OpenFileDialog

theDialog = dotNetObject "System.Windows.Forms.OpenFileDialog" --create a OpenFileDialog
theDialog.title = "PLEASE Select One Or More Files" --set the title
theDialog.Multiselect = true --allow multiple files to be selected
theDialog.Filter = "HTML Files (*.html)|*.html|All Files (*.*)|*.*" --specify the filter
theDialog.FilterIndex = 2 --set the filter drop-down list to All Files
result = theDialog.showDialog() --display the dialog, get result into variable
result.ToString() --when closed, convert the result to string
result.Equals result.OK --returns TRUE if OK was pressed, FALSE otherwise
result.Equals result.Cancel --returns TRUE if Cancel was pressed, FALSE otherwise
theFilenames = theDialog.fileNames --the selected filenames will be returned as an array

 

你可能感兴趣的:(windows)