User's Guide > Session Objects > File Dialogs
File Dialogs
Methods Introduced:
The method pfcSession.UIOpenFile() opens the relevant dialog box for browsing directories and opening files. The method lets you specify several options through the input arguments pfcFileOpenOptions and pfcFileUIOptions.
Use the method pfcFileOpenOptions.Create() to create a new instance of the pfcFileOpenOptions object. This object contains the following options:
FilterString—Specifies the filter string for the type of file accepted by the dialog box. Multiple file types should be listed with wildcards and separated by commas, for example, *.prt, *.asm, *.txt, *.avi, and so on. Use the property pfcFileOpenOptions.FilterString to set this option.
PreselectedItem—Specifies the name of an item to preselect in the dialog box. Use the property pfcFileOpenOptions.PreselectedItem to set this option.
The pfcFileUIOptions object contains the following options:
DefaultPath—Specifies the name of the path to be opened by default in the dialog box. Use the property pfcFileUIOptions.DefaultPath to set this option.
DialogLabel—Specifies the title of the dialog box. Use the property pfcFileUIOptions.DialogLabel to set this option.
Shortcuts—Specifies an array of file shortcuts of the type pfcFileOpenShortcut. Create this object using the method pfcFileOpenShortcut.Create(). This object contains the following attributes:
ShortcutName—Specifies the name of shortcut path to be made available in the dialog box.
ShortcutPath—Specifies the string for the shortcut path.
Use the property pfcFileUIOptions.Shortcuts to set the array of file shortcuts.
The method pfcSession.UIOpenFile() returns the file selected by you. The application must use other methods or techniques to perform the desired action on the file.
The method pfcSession.UISaveFile() opens the relevant dialog box for saving a file. The method accepts options similar to pfcSession.UIOpenFile() through the PFCFileSaveOptions and pfcFileUIOptions objects. Use the method pfcFileSaveOptions.Create() to create a new instance of the pfcFileSaveOptions object. When using the Save dialog box, you can set the name to a non-existent file. The method pfcSession.UISaveFile() returns the name of the file selected by you; the application must use other methods or techniques to perform the desired action on the file.
The method pfcSession.UISelectDirectory() prompts the user to select a directory using the Creo Parametric dialog box for browsing directories. The method accepts options through the pfcDirectorySelectionOptions object which is similar to the pfcFileUIOptions object (described for the method pfcSession.UIOpenFile()). Specify the default directory path, the title of the dialog box, and a set of shortcuts to other directories to start browsing. If the default path is specified as NULL, the current directory is used. Use the method pfcFileOpenOptions.Create() to create a new instance of the pfcDirectorySelectionOptions object. The method pfcSession.UISelectDirectory() returns the selected directory path; the application must use other methods or techniques to perform other relevant tasks with this selected path.
Was this helpful?