rootx Posted December 1, 2016 Posted December 1, 2016 (edited) 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 December 1, 2016 by rootx
Moderators JLogan3o13 Posted December 1, 2016 Moderators Posted December 1, 2016 @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!
jguinch Posted December 1, 2016 Posted December 1, 2016 9 minutes ago, JLogan3o13 said: @rootx When you select multiple files option it returns an array, 0 index is path and the rest are filenames. After StringSplit, yes Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Moderators JLogan3o13 Posted December 1, 2016 Moderators Posted December 1, 2016 @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!
rootx Posted December 1, 2016 Author Posted December 1, 2016 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now