Jump to content

FileOpenDialog multiple files path ? [SOLVED]


rootx
 Share

Recommended Posts

Why if I select only one file the array doesn't return the path?? And 4 multiple files return the row PATH? There is a mode to have in the same case signle or multiple selection the path included in the file name? THX

#include <Array.au3>
#include <File.au3>

Local $spFile

$mFile = FileOpenDialog("apri", @ScriptDir & "", "Images (*.iso)", 1 + 4 )
If @error Then
    ConsoleWrite("error")
Else
    $spFile = StringSplit($mFile, "|")
EndIf

_ArrayDisplay($spFile)

 

Edited by rootx
Link to comment
Share on other sites

  • Moderators

@rootx when you specify single file, FileOpenDialog returns a String of full path. When you select multiple files option it returns an array, 0 index is path and the rest are filenames. If you want full path for all files, either loop through the array and concatenate the 0 index to the file name, or (easier) just use _FileListToArray and choose the $bReturnPath = True option.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

@jguinch I didn't see the need to go into exactly how it creates the array, don't know that knowing it does a stringsplit helps him any. But yes, you are correct.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

My solution....

#include <Array.au3>
#include <File.au3>

Local $spFile

$mFile = FileOpenDialog("apri", @ScriptDir & "", "Images (*.iso)", 1 + 4 )
If @error Then
    ConsoleWrite("error")
Else
    $spFile = StringSplit($mFile, "|")
     If UBound($spFile) = 2 Then
         MsgBox("","","one file")
         ConsoleWrite($spFile[1]&@CRLF)
     Else
         MsgBox("","","more than two files")
         $path = $spFile[1]
         _ArrayDelete($spFile, 0)
         _ArrayDelete($spFile, 0)
         For $x = 0 to UBound($spFile)-1
             ConsoleWrite($path&$spFile[$x]&@CRLF)
         Next
    EndIf
EndIf

 

Link to comment
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
 Share

×
×
  • Create New...