简体   繁体   中英

Appending to an Avro file in C#

I want to append data to an Avro file. The data has the same schema as the rest of the Avro file. I saw Java's appendTo method which seems to do it. Is there a way for me to do this in C#?

See File.AppendText

Example from docs:

    string path = @"c:\temp\MyTest.txt";
    // This text is added only once to the file.
    if (!File.Exists(path))
    {
        // Create a file to write to.
        using (StreamWriter sw = File.CreateText(path))
        {
            sw.WriteLine("Hello");
            sw.WriteLine("And");
            sw.WriteLine("Welcome");
        }   
    }

    // This text is always added, making the file longer over time
    // if it is not deleted.
    using (StreamWriter sw = File.AppendText(path))
    {
        sw.WriteLine("This");
        sw.WriteLine("is Extra");
        sw.WriteLine("Text");
    }   

    // Open the file to read from.
    using (StreamReader sr = File.OpenText(path))
    {
        string s = "";
        while ((s = sr.ReadLine()) != null)
        {
            Console.WriteLine(s);
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM