Anhängen Textdatei mit streamwriter

Habe ich diesen code, wo ich den folgenden code ausführen, in der Reihenfolge.

Werde ich immer erstellen Sie eine neue text-Datei an den Anfang. dann für die 2. und 3. Teil des Codes brauche ich nur zum Anhängen der text Datei "checksnapshot" wie mache ich das mit streamwriter?

//1
using (StreamReader sr = new StreamReader("C:\\Work\\labtoolssnapshot.txt")) ;
{
    string contents = sr.ReadToEnd();
    using (StreamWriter sw = new StreamWriter("C:\\Work\\checksnapshot.properties"))
    {
        if (contents.Contains(args[0]))
        {
            sw.WriteLine("SASE= 1");
        }
        else
        {
            sw.WriteLine("SASE= 0");
        }
    }
}

//2
using (StreamReader sr = new StreamReader("C:\\Work\\analyzercommonsnapshot.txt")) ;
{
    string contents = sr.ReadToEnd();
    using (StreamWriter sw = new StreamWriter("C:\\Work\\checksnapshot.properties"))
    {
        if (contents.Contains(args[0]))
        {
            sw.WriteLine("Analyzer= 1");
        }
        else
        {
            sw.WriteLine("Analyzer= 0");
        }
    }
}

//3
using (StreamReader sr = new StreamReader("C:\\Work\\mobilesnapshot.txt")) ;
{
    string contents = sr.ReadToEnd();
    using (StreamWriter sw = new StreamWriter("C:\\Work\\checksnapshot.properties"))
    {
        if (contents.Contains(args[0]))
        {
            sw.WriteLine("mobile= 1");
        }
        else
        {
            sw.WriteLine("mobile= 0");
        }
    }
}
InformationsquelleAutor jeremychan | 2011-05-31
Schreibe einen Kommentar