Jump to content

formatting result of $fileopendialog


Recommended Posts

OK, so I have a fileopendialog box, which will limit the user to finding an .msi file. It then outputs that to a GUI input box.

it outputs it as a full path, eg. c:\test\test1\hi.msi but i then need to have just the msi filename output to an ini file.

I can't do stringright or stringtrim as each msi will be a different name so there is no set number. is there any way of it converting c:\xxxx\hi.msi to hi.msi

i thought about a string split using "\" as the delimiter but i haven't used stringsplit enough to know if its possible or how to do it exactly.

any help would be appreciated!

Thanks

**edit**

this is what i have so far:

$localmsifile = FileOpenDialog("", "c:\", "MSI Files (*.msi)", 1 + 2)
    GUICtrlSetData($localmsifileinput, $localmsifile)

so i need it to somehow strip everything up to the actual filename from $localmsifile if its possible

Edited by darkleton
Link to comment
Share on other sites

  • Moderators

darkleton,

This will get you the file name and extension from a full path: :mellow:

$sFileName = StringRegExpReplace($localmsifile, "^.*\\", "")

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I use this to select a sound file, but in the input box only the filename (w/o the ext.) is displayed. I'm sure you can use this as an example to do what you want.

Func GetSoundFile()
    $sSelectedSong = FileOpenDialog("Select Song", "C:\Users\Public\Music\Music", "Media files (*.mp3;*.wav;*.m4a) | All (*.*)")
    $MusicPath = StringSplit($sSelectedSong, "\")
    GUICtrlSetData($Input3, StringTrimRight($MusicPath[$MusicPath[0]], 4))
EndFunc   ;==>GetSoundFile

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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...