One of the requirements for my AIR application is to copy
large files from one location to another on the client computer.
I've been using the copyToAsync() method in AIR, but unfortunately
this does not trigger progress events. Copying gigabyte files that
take several seconds becomes pretty uncomfortable for users, when
they can't see the progress.
Does anyone know of an alternative or workaround? All I need
to do is copy a file from one location to another, and measure the
progress while that is happening.
Since I control the client machines (it is a closed
environment), I have the option to setup file servers on every
machine and use the file download control with Flash instead of
file copy. However, when I investigate this option it seems that
the file download control will always trigger user interaction to
select the target path (which I don't want -- I want to
programatically select the source files and the target directory).
If someone knows a solution to that problem I would happily take it
and move on :)
Use 2 FileStream objects in async mode (openAsync). One to
read and another to write. When you read in async mode, you get
progress events. When they fire, you can read bytesAvailable
amounts of data and write that to the output filestream.
The output filestream can listen for output_progress events
to ensure that new data can be written to it or not.
Functionally, this works great... however, there is an issue.
The openAsync() method reads the entire file into memory, and some
of the files are huge. Is there a way to set the read buffer size,
so that I only read a chunk of the file at a time?