Jump to content

Possible to get number of files selected with FileOpenDialog?

Go to solution Solved by BigDaddyO,

Recommended Posts


I'm trying to get FileOpenDialog to return the number of files selected rather than displaying the filename themselves as per the default example in the help file. eg. How many zip files were selected by the dialog box.

eg. Local $sFileOpenDialog = FileOpenDialog($sMessage, $sourcefolder & "\", "Zip (*.zip;*.rar)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT))

Local $sFileOpenDialog = FileOpenDialog($sMessage, $sourcefolder & "\", "Zip (*.zip;*.rar)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT))
Local $files = _FileListToArray($sFileOpenDialog, "*", 1)
Local $count = $files[0]

I get the following error:

==> Subscript used on non-accessible variable.:

Global $filecount = $files[0]
Global $filecount = $files^ ERROR

How do you access that first part of the array as per the help file?

Return Value


A one-dimensional array.
    $aArray[0] = Number of Files\Folders returned
    $aArray[1] = 1st File\Folder
    $aArray[2] = 2nd File\Folder
    $aArray[3] = 3rd File\Folder
    $aArray[n] = nth File\Folder

Link to post
Share on other sites


FileOpenDialog:  https://www.autoitscript.com/autoit3/docs/functions/FileOpenDialog.htm
Return Value 
Success: the full path of the file(s) chosen. Results for multiple selections are "Directory|file1|file2|...".

StringReplace: https://www.autoitscript.com/autoit3/docs/functions/StringReplace.htm
Return Value
Returns the new string with the number of replacements performed stored in the @extended macro.

Example: StringReplace("Directory|file1|file2|file3|file4", "file", "file") and you find number of files after in @extended

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...