Jump to content

FileChangeDir Question


Recommended Posts

Hi just want to ask why am I getting the return success value of destination path "C:\yahoo\1" ?

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()

    Local $sFileSaveDialog = FileSaveDialog("Choose a filename.", "", "All Files(*.*)", $FD_PATHMUSTEXIST + $FD_MULTISELECT)
    $SaveDir = FileCopy($sFileSaveDialog, "", $FC_OVERWRITE)
    $GetPath = _WinAPI_GetFullPathName($sFileSaveDialog)
    ; Display the current working directory.
    MsgBox($MB_SYSTEMMODAL, "", "The current working directory: " & @CRLF & $GetPath)

    $sChangeDir = FileChangeDir("C:\yahoo") ;--> Path I want to get "C:\yahoo"
    $GetPath1 = _WinAPI_GetFullPathName($sChangeDir)
    If $sChangeDir = 0 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error")
        Exit
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Succes" & @CRLF & $GetPath1) ;--> Path I got "C:\yahoo\1"
    EndIf


EndFunc   ;==>Example

I ran the example in helpfile and its working fine, is this a bug???

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

OMG, Im a total noob... never thought of that... thank you... :sweating::sweating::sweating:

Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

@mikell

sorry bout this but sometimes I get confused with so many codes :sweating::sweating::sweating:, I always check help file, google, and auto it wiki...

 

Quote

Edit
In this case though, the winapi thing is redundant. Why not directly check @workingdir ?

 

I tried like this and I got Value of 1, instead of string path...

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()

    Local $sFileSaveDialog = FileSaveDialog("Choose a filename.", "", "All Files(*.*)", $FD_PATHMUSTEXIST + $FD_MULTISELECT)
    $SaveDir = FileCopy($sFileSaveDialog, "C:\yahoo", $FC_OVERWRITE)
    $GetPath = _WinAPI_GetFullPathName($sFileSaveDialog)
    ; Display the current working directory.
    MsgBox($MB_SYSTEMMODAL, "", "The current working directory: " & @CRLF & $GetPath)

    $sChangeDir = FileChangeDir(@WorkingDir) ;--> Path I want to get "C:\yahoo"
;~     $GetPath1 = _WinAPI_GetFullPathName(@WorkingDir)
;~     If $sChangeDir = 0 Then
;~         MsgBox($MB_SYSTEMMODAL, "", "Error")
;~         Exit
;~     Else
        MsgBox($MB_SYSTEMMODAL, "", "Succes" & @CRLF & $sChangeDir) ;--> Path I got "1"
;~     EndIf


EndFunc   ;==>Example

 

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

  • Moderators

232showtime,

Does this make it clearer?

#include <MsgBoxConstants.au3>
#include <FileConstants.au3>

Example()

Func Example()

    Local $sFileSaveDialog = FileSaveDialog("Choose a filename.", "", "All Files(*.*)", $FD_PATHMUSTEXIST + $FD_MULTISELECT)

    ;$GetPath = _WinAPI_GetFullPathName($sFileSaveDialog) ; Why do you do this, you already get the full path returned from the function call

    ; Display the current working directory.
    MsgBox($MB_SYSTEMMODAL, "", "The current working directory: " & @CRLF & $sFileSaveDialog)

    ; Now change the working folder
    $iRet = FileChangeDir("M:\Program")
    If $iRet = 0 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error")
        Exit
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Succes" & @CRLF & @WorkingDir)
    EndIf


EndFunc   ;==>Example

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

@Melba23

first time user of $sFileSaveDialog, no idea that it will return the full path returned from function call :sweating::sweating::sweating:

basicallyI wanted to get the filepath of the files that I copied using FileCopy. I did so many workaround and I landed on my 1st post of script. its clear now . by the way is there any other way to get the file path of the file that I copied using filecopy???

Local $sFileSaveDialog = FileSaveDialog("Choose a filename.", "", "All Files(*.*)", $FD_PATHMUSTEXIST + $FD_MULTISELECT)
    
    $SaveDir = FileCopy($sFileSaveDialog, "C:\yahoo", $FC_OVERWRITE); ---------------------in this line I Want to Get "C:\yahoo" instead of the current working dir... in my case Save Dialog box working dir is C:\Users\user\Pictures.. so im getting the path of C:\Users\user\Pictures instead of "C:\yahoo"
    
    
    $GetPath = _WinAPI_GetFullPathName($SaveDir) ;--> I want t see what will happen here
    ; Display the current working directory.
    MsgBox($MB_SYSTEMMODAL, "", "The current working directory: " & @CRLF & $GetPath)

many thanks @Melba23 & @mikell

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

Hmm it seems that you are confusing several things. Please try this :

#include <FileConstants.au3>
#Include <Array.au3>
#include <StringConstants.au3>

Local $sFileOpenDialog = FileOpenDialog("Choose a filename.", "", "All Files(*.*)", $FD_PATHMUSTEXIST + $FD_MULTISELECT)

If not @error Then
   MsgBox(0,"FileOpenDialog return", $sFileOpenDialog)
   $aSave = StringSplit($sFileOpenDialog, "|")
  _ArrayDisplay($aSave, "FileOpenDialog array")
  $destDir = "C:\yahoo\"    ;<<< don't forget the backslash !
  For $i = 2 to $aSave[0]
     FileCopy($aSave[1] & "\" & $aSave[$i], $destDir, $FC_CREATEPATH + $FC_OVERWRITE)
  Next
EndIf
ShellExecute($destDir )

 

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