Jump to content

Openfiledialog getting file name


Recommended Posts

Hello, I added openfiledialog function into my script. I would like to get opened file name without direction. :rolleyes:

Example : Selected files in openfiledialog "C:\Users\Terron\Desktop\newfile.txt"  =>   "newfile.txt"  <<= I would like to get this name

Which function should I add in the script?     

Thanks...:)

Link to comment
Share on other sites

also possible :

$sRet="C:\Program Files\AutoIt3\Examples\GUI\merlin.gif"    ;this simulate the returnstring of fileopendialog without  $FD_MULTISELECT
$sWanted=StringMid($sRet,StringInStr($sRet,'\',0,-1)+1)     ;this is the combination of funcs you can use
MsgBox(0,'filename only',$sWanted)

if $FD_MULTISELECT is used you have to use StringSplit:

#include <Array.au3>
$sRet=  "C:\Program Files\AutoIt3\Examples\GUI|logo4.gif|merlin.gif"    ;this simulate the returnstring of fileopendialog with $FD_MULTISELECT
$aWanted=StringSplit($sRet,'|',2)
_arraydisplay($aWanted) ;this is the array of returnstring REMEMBER $aWandted[0]=Path, all others filenames without path

 

Edited by AutoBert
Link to comment
Share on other sites

Just now, AutoBert said:

also possible :

$sRet="C:\Program Files\AutoIt3\Examples\GUI\merlin.gif"    ;this simulate the returnstring of fileopendialog without  $FD_MULTISELECT
$sWanted=StringMid($sRet,StringInStr($sRet,'\',0,-1)+1)     ;this is the combination of funcs you can use
MsgBox(0,'filename only',$sWanted)

if $FD_MULTISELECT is used you have to use StringSplit:

#include <Array.au3>
$sRet=  "C:\Program Files\AutoIt3\Examples\GUI|logo4.gif|merlin.gif"    ;this simulate the returnstring of fileopendialog with $FD_MULTISELECT
$aWanted=StringSplit($sRet,'|',2)
_arraydisplay($aWanted) ;this is the array of returnstring REMEMBER $aWandted[0]=Path, all others filenames without path

 

It is working. Thanks a lot.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...