Example: Check if a file exists

public static int main (string[] args) {
File file = File.new_for_path ("my-test.txt");

// Check if a particular file exists:
bool tmp = file.query_exists ();
if (tmp == true) {
print ("File exists\n");
} else {
print ("File does not exist\n");
}

return 0;
}

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

See:




2022 vala-language.org