Re: [Vala] Downloading a file from the internet to some directory.



Arkadi Viner wrote:
Hello every body.

My program needs to download some file from the internet each time it
starts,
how to accomplish that mission?

Is there a gtk librery to do it or i have to use the webkit library?

Thanks.

Hi,

--------------------------------------------------------------------
void main () {
        var src = File.new_for_uri ("http://download.gnome.org/sources/vala/0.7/vala-0.7.6.tar.bz2";);
        var dst = File.new_for_path ("vala-0.7.6.tar.bz2");
        try {
                src.copy (dst, FileCopyFlags.NONE, null, null);
        } catch (Error e) {
                stderr.printf ("%s\n", e.message);
        }
}

--------------------------------------------------------------------
$ valac download.vala --pkg gio-2.0

Alternatively use 'copy_async()' for asynchronous copying.


Best regards,

Frederik



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]