delete_async


Description:

[ CCode ( vfunc_name = "delete_file_async" ) ]
[ Version ( since = "2.34" ) ]
public virtual async bool delete_async (int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error

Asynchronously delete a file.

If the this is a directory, it will only be deleted if it is empty. This has the same semantics as unlink.

Example: Delete a file, async:

public static int main (string[] args) {
MainLoop loop = new MainLoop ();

// Delete my-test.txt:
File file = File.new_for_path ("my-test.txt");
file.delete_async.begin (Priority.DEFAULT, null, (obj, res) => {
try {
bool tmp = file.delete_async.end (res);
print ("Result: %s\n", tmp.to_string ());
} catch (Error e) {
print ("Error: %s\n", e.message);
}

loop.quit ();
});

loop.run ();
return 0;
}

valac --pkg gio-2.0 GLib.File.delete_async.vala

Parameters:

this

input File

io_priority

the I/O priority of the request

cancellable

optional Cancellable object, null to ignore

callback

a TaskReadyCallback to call when the request is satisfied

user_data

the data to pass to callback function