[Vala] Writing to existing file



Hi , Guys

I am trying to write to an existing file but I found only a write to a new file in http://code.valaide.org

code like this :
var file = File.new_for_path ("samplefile.txt");
        {
            var file_stream = file.create (FileCreateFlags.NONE, null);

            if (file.query_exists (null)) {
                stdout.printf ("File successfully created.\n");
            }

            var data_stream = new DataOutputStream (file_stream);
            data_stream.put_string ("Hello, world", null);
        }

What I want is to change this line
var file_stream = file.create (FileCreateFlags.NONE, null); to something like

var file_stream = file.open ();
var data_stream = new DataOutputStream (file_stream);

How can I accomplish this ?




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