Sign in to follow this  
Followers 0
emmanuel

Urldownloadtofile

3 posts in this topic

#1 ·  Posted (edited)

will URLDownloadToFile create the directory in it's second parameter if it doesn't already exist?

example: URLDownloadToFile ( "URL", "c:\downloads\folder_that_wasn't_there" )

here's the code I'm using it in... The URLDownloadtoFile appears to run, I see the tooltip, but I can't find the files...

#cs
   script to download latest build, backup existing install and install latest build.
   grabs the following files from $szBaseURL
   Aut2Exe.exe
   AutoIt.chm
   AutoIt3.exe
   AutoItSC.bin
#ce

$szBaseURL = "http://www.autoitscript.com/autoit3/files/unstable/autoit/"
$szDownloadDir = @ScriptDir & "\download"
$szAutoItFolder = @ProgramFilesDir & "\AutoIt3"

;download latest build

getfile($szBaseURL & "Aut2Exe.exe", "new\Aut2Exe.exe")
getfile($szBaseURL & "AutoIt.chm", "new\AutoIt.chm")
getfile($szBaseURL & "AutoIt3.exe", "new\Aut2exe\AutoIt3.exe")
getfile($szBaseURL & "AutoItSC.bin", "new\Aut2exe\AutoItSC.bin")
MsgBox(0,"after getfile","still here")

;backup existing version to folder of version name
BackupCurrent($szAutoItFolder & "\Aut2Exe.exe")
BackupCurrent($szAutoItFolder & "\AutoIt.chm")
BackupCurrent($szAutoItFolder & "\Aut2Exe\AutoIt3.exe")
BackupCurrent($szAutoItFolder & "\Aut2Exe\AutoItSC.bin")
MsgBox(0,"after backupcurrent","still here")
;copy downloaded files

Func getfile($szFile, $szTarget)
   If Not FileExists($szDownloadDir) Then
      DirCreate($szDownloadDir)
   EndIf
   TrayTip("Downloading...", $szFile, 10)
   URLDownloadToFile($szBaseURL & $szfile,$szDownloadDir & "\" & $szTarget)
EndFunc  ;==>getfile

func BackupCurrent($szFile)
   $szVer = FileGetVersion(@ProgramFilesDir & "\AutoIt3\Autoit3.exe")
  ;MsgBox(0,"ver","ver is" & $szVer)
   $szBackupDir = "backup\" & $szVer
  ;MsgBox(0,"backupdir","backupdir is" & $szBackupDir)
   if not FileExists($szBackupDir) Then
      DirCreate($szBackupDir)
     ;   MsgBox(0,"dir","dir created")
   EndIf
   TrayTip("Backing up...", $szFile, 30)
   FileCopy($szFile , $szBackupDir)
EndFunc  ;==>BackupCurrent
Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites



I concur, given that I can't find those files anywhere... will do a dircreate and then work in some error checking


"I'm not even supposed to be here today!" -Dante (Hicks)

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
Sign in to follow this  
Followers 0