URLDownloadToFile question

URLDownloadToFile question

Postby Marc Vanzegbroeck » Fri Feb 10, 2012 7:44 am

Hi,

I have 2 questions

1.
I'm using 'URLDownloadToFile' to dowload updates for my programs.
The problem is that the filedate/time of the downloaded file is the time of downloading. Is there a possibility to keep the original file-creation date/time?

2.
Now I'm downloading to an other file name, and than stop the program, rename the file and start again because at the time of downloading, the EXE is in use. Is it possible to overwrite the exe while it is still running?

Thanks.
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: URLDownloadToFile question

Postby frose » Fri Feb 10, 2012 10:30 am

Marc,

1. SetFdati( cTargetFile, FileDate( cSourceFile ), FileTime( cSourceFile ) )

2. No, I don't think so. I'm copying to new file name(s), e. g. "cTargetFile_update", generating and starting a batch file with a time delay and quits the program. The batch file contains these commands:

Code: Select all  Expand view

FWrite( nFileHandle, [CHOICE /M "Wait eight seconds until the app is terminated!" /T 8 /D N] + CRLF )
// delete all existing files
FWrite( nFileHandle, "if exist " + aDateien_lokal[ i, 1 ] + " del " + aDateien_lokal[ i, 1 ] + CRLF )
// rename all '..._update' files
FWrite( nFileHandle, "ren " + cPathEXE + aDateien_update[ i, 1 ] + " " + aDateien_lokal[ i, 1 ] + CRLF )
// if you like, start the updated app
FWrite( nFileHandle, Get_PathFileName_Exe()+ CRLF )
 

The app displays the date of the app in red if the update fails, so the user has an indicator.
It's not perfect, but there is no need of another app (update.exe) and in most cases it works quite well :wink:
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: URLDownloadToFile question

Postby Marc Vanzegbroeck » Fri Feb 10, 2012 11:09 am

Thanks Frank,

I was also using a batch-file to delete the old exe-file and to rename the new one, but didn't know how to wait.
Now I added 'CHOICE /M "Wait eight seconds until the app is terminated!" /T 8 /D N] + CRLF ', and now it's working fine.

The problem with the 'SetFdati( cTargetFile, FileDate( cSourceFile ), FileTime( cSourceFile ) )' is that I don't know the original date/time of the file after the download. But I can create a text-file with the date/time information, and download also this from the web-site, and then change de date/time

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: URLDownloadToFile question

Postby frose » Fri Feb 10, 2012 12:08 pm

Marc,

understand.

Or you add a date/time stamp to the update file name, like "..._20120210-124651.exe"

I've forgotten to mention, that choice.exe is not present on every (XP) system, so you have to deploy a suitable one :!:
I'm using the version 5.2.3790.0 without problems.
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: URLDownloadToFile question

Postby Marc Vanzegbroeck » Fri Feb 10, 2012 12:34 pm

Frank,

I can't add the data/time to the update file-name, because then I the filename to download allways change and I already need to know the date/time of the file before downloading. And if I know them, I don't need them in the filename :)

The 'choice.exe' is working fine on the 'Vista' and 'Windows7' system I'am using. I will verify on my XP-systems.

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 90 guests