# MultiFileSelectPopup

int MultiFileSelectPopup (char defaultDirectory[], char defaultFileSpec[], char fileTypeList[], char title, int restrictDirectory, int restrictExtension, int allowCancel, int *numberOfSelectedFiles, char **fileList);

## Purpose

Displays a multi-file selection dialog box and waits for the user to select a set of files or cancel.

## Parameters

Input
Name | Type | Description
defaultDirectory | string | Initial directory. If you enter "", the function uses the current working directory.
| Note If you set restrictDirectory to Yes, "" is not valid for defaultDirectory. You must pass a valid directory name in this case.
defaultFileSpec | string | String that specifies which files to display. For example, "*.c" causes all files with the .c extension to be displayed. The defaultFileSpec appears in the filename box when you initially display the pop-up dialog box. If you specify an actual filename, such as test.c, that name appears in the filename box and also in the file list box. defaultFileSpec cannot contain a directory path.
fileTypeList | string | List of file types, separated by semicolons, to display in the file type list of the File Select pop-up dialog box when restrictExtension is FALSE. For example, "*.c;*.h" allows the user to select "*.c" or "*.h" from the file type list. The all files, *.*, option is always available.
title | string | Title of the dialog box.
restrictDirectory | integer | If nonzero, the user cannot change directories or drives. If zero, the user can change directories or drives.
restrictExtension | integer | If nonzero, the user is limited to files with the default extension. If zero, the user can select files with any extension.
allowCancel | integer | If nonzero, the user can cancel out of the File Select pop-up dialog box. If zero, the user can leave the pop-up dialog box only by making a selection.
Output
Name | Type | Description
numberOfSelectedFiles | integer | Number of files selected by the user.
fileList | string | Buffer that contains an array of strings, where each string is the name of one of the files selected. The last element of the array is a NULL pointer. The buffer is automatically allocated by MultiFileSelectPopup and is accessible as an array of strings. When you no longer need them, free each string and the array with the free function. The following example illustrates how to free each string in the file list and then free the file list array itself. char **fileList = NULL, **ppc = NULL; int numFiles; int status; int i; status = MultiFileSelectPopup ("", "*.*", "", "", 0, 0, 1, &numFiles, &fileList); if (status >= 0) { if (fileList) { /* Using for loop to iterate through selected files */ for (i=0; i<numFiles; ++i) { printf ("Selected File : %s\n", fileList [i]); free (fileList [i]); fileList [i] = NULL; } /* Instead of for loop, can also do ppc = fileList; while (*ppc) { printf ("Selected File : %s\n", *ppc); free (*ppc); *ppc = NULL; ppc++; } */ free (fileList); fileList = NULL; } }

## Return Value

Name | Type | Description
selectionStatus | integer | The selection status or error codes generated during the function call.
0 | VAL_NO_FILE_SELECTED
1 | VAL_EXISTING_FILE_SELECTED
2 | VAL_NEW_FILE_SELECTED
Negative values indicate that an error occurred.