Jump to content
Skeletor

FileSaveDialog Variable Folder (Solved)

Recommended Posts

Skeletor

Hi Guys,

Point me in the right direction. I've been trying to make the FileSaveDialog command point to a variable directory.

Basically, user inserts data into the inputs, that is then read out and the directory should be created.

Then FileSaveDialog is set to save this file to that directory.

 

See my code and we can discuss further.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Demo", 160, 130, 192, 124)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenuItem("Save", $MenuItem1)
$Input1 = GUICtrlCreateInput("Input1", 8, 32, 145, 21)
GUICtrlSetData($Input1,"")
$Input2 = GUICtrlCreateInput("Input2", 8, 64, 145, 21)
GUICtrlSetData($Input2,"")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $MenuItem2
    $Input1_Read = GUICtrlRead($Input1)
    $Input2_Read = GUICtrlRead($Input2)
    $path = ("C:\temp\users\")
    Local $Directory = DirCreate($path & $Input1_Read & " " & $Input2_Read & "\" & "Profile")
    $filesave = FileSaveDialog("Save File", $Directory, "Text File (*.txt)", 16, $Input1_Read & " " & $Input2_Read)

    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites
SlackerAl

Your problem is: 

Local $Directory = DirCreate($path & $Input1_Read & " " & $Input2_Read & "\" & "Profile")

DirCreate returns 1 on successful creation of the directory, not the new directory path. Try this instead:

$Directory = $path & $Input1_Read & " " & $Input2_Read & "\" & "Profile"
DirCreate($Directory)

You should check the creation was successful and have some error trapping, but with the correct input this will work.

  • Like 1

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Share this post


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

×