Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Stream Writer, and Reader

$
0
0
I have this very simple method that is writing data from String builder to CSV file.

        public void WriteCSV(StringBuilder SB)
        {
            FileInfo finfo = new FileInfo("Books.csv");
            FileStream fs = finfo.Create();
            // Initialise stream object with file
            using (var wr = new StreamWriter(fs))
            {
                
                
                var sb = SB;
                
                // write output to file
                wr.WriteLine(sb.ToString());
            }
        }

This writers the new data everytime, But I want to start writing after previously written data. I think my code is creating the file everytime. For example if I call this method for the first time. It writes some text "ABCDE". Next time It should check if there is already some text. and Writer the new text after previous text like. ABCDE XXXXY.

Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>