/* Asynchronous GIO in Vala sample code */ using Gtk; /** * Loads the list of files in users home directory and displays them * in a GTK+ list view. */ public class ASyncGIOSample : Gtk.Window { private File dir; private Gtk.ListStore model; construct { this.setup (); } /* Set up the window and widget */ private void setup () { var sc = new Gtk.ScrolledWindow (null, null); sc.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC); var tv = new Gtk.TreeView (); sc.add (tv); tv.
static int main (string[] args) { try { // Reference a BMP image file var file = File.new_for_uri ("http://wvnvaxa.wvnet.edu/vmswww/images/test8.bmp"); // var file = File.new_for_path ("sample.bmp"); // Open file for reading var file_stream = file.read (null); var data_stream = new DataInputStream (file_stream); data_stream.set_byte_order (DataStreamByteOrder.LITTLE_ENDIAN); // Read the signature uint16 signature = data_stream.read_uint16 (null); if (signature != 0x4d42) { stderr.prin
static int main (string[] args) { try { // Reference a local file name var file = File.new_for_path ("samplefile.txt"); { // Create a new file with this name var file_stream = file.create (FileCreateFlags.NONE, null); // Test for the existence of file if (file.query_exists (null)) { stdout.printf ("File successfully created.\n"); } // Write text data to file var data_stream = new DataOutputStream (file_stream); data_stream.put_string (
static int main (string[] args) { // A reference to our file var file = File.new_for_path ("data.txt"); if (!file.query_exists (null)) { stderr.printf ("File '%s' doesn't exist.\n", file.get_path ()); return 1; } try { // Open file for reading and wrap returned FileInputStream into a // DataInputStream, so we can read line by line var in_stream = new DataInputStream (file.read (null)); string line; // Read lines until end of file (null) is reached while ((line = in_stream.read_line (null, null)