Re: CopyFile API causes no response from application
From: Eric den Doop (ericdendoop_at_xspamblockxfoxite.com)
Date: 06/13/04
- Next message: Cowboy: "Filter"
- Previous message: kd: "SQL Cursors"
- In reply to: Glenn Aitchison: "CopyFile API causes no response from application"
- Next in thread: Anders Altberg: "Re: CopyFile API causes no response from application"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 13 Jun 2004 16:05:29 +0200
Hello, Glenn!
You wrote on Sun, 13 Jun 2004 21:24:22 +1200:
GA> When I use the copyfile api call and I come to a big file then it
GA> causes my application to not respond. I want to show the file being
GA> copied on a progress bar likes windows explorer does.
You can't do that with the COPY FILE command. You can display a WAIT
WINDOW...
WAIT WINDOW "Please wait while copying file ....." NOWAIT
COPY FILE ...
WAIT CLEAR
If you really want to display your own progress bar dialog, then you copy
small parts of the file like in this example:
<vfp_code>
lnSourceFileHandle = FOPEN("yourfile.exe")
* go eof
lnFileSize = FSEEK(lnSourceFileHandle, 0, 2)
* go bof
FSEEK(lnSourceFileHandle, 0, 0)
* read 1024 bytes
lnBlockSize = 1024
lnBytesWritten = 0
* create target file
lnTargetFileHandle = FCREATE("target.exe")
FOR lnCount = 1 TO lnFileSize / lnBlockSize
WAIT WINDOW "Copying file....: " + ;
TRANSFORM((lnBytesWritten / lnFileSize)*100) + ;
"% completed." NOWAIT
lcFileData = FREAD(lnSourceFileHandle, lnBlockSize)
FWRITE(lnTargetFileHandle, lcFileData)
lnBytesWritten = lnBytesWritten + lnBlockSize
ENDFOR
lnLastBytes = MOD(lnFileSize, lnBlockSize)
IF lnLastBytes > 0
lcFileData = FREAD(lnSourceFileHandle, lnLastBytes)
FWRITE(lnTargetFileHandle, lcFileData)
ENDIF
FCLOSE(lnSourceFileHandle)
FCLOSE(lnTargetFileHandle)
WAIT WINDOW "Done!" TIMEOUT 2
</vfp_code>
Another option is to use the Windows API to copy the file. I don't have a
sample available, but I know it is possible to call the same copy-function
that is used by windows explorer (including windows' progress dialog).
-- Eric den Doop www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
- Next message: Cowboy: "Filter"
- Previous message: kd: "SQL Cursors"
- In reply to: Glenn Aitchison: "CopyFile API causes no response from application"
- Next in thread: Anders Altberg: "Re: CopyFile API causes no response from application"
- Messages sorted by: [ date ] [ thread ]