I want to write a csv file in the append mode in vb .net 2010

I want to write a csv file in the append mode in vb .net 2010
1030071002Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
You can use a streamwriter.
http://dotnetperls.com/streamwriter-vbnet 
0
Om PrakashCommented:

Dim path As String = "c:\temp\MyTest.txt"
        Dim sw As StreamWriter

        ' This text is added only once to the file.
        If File.Exists(path) = False Then
            ' Create a file to write to.
            sw = File.CreateText(path)

            sw.WriteLine("Hello")
            sw.WriteLine("And")
            sw.WriteLine("Welcome")
            sw.Flush()
            sw.Close()
        End If

        ' This text is always added, making the file longer over time
        ' if it is not deleted.
        sw = File.AppendText(path)
        sw.WriteLine("This")
        sw.WriteLine("is Extra")
        sw.WriteLine("Text")
        sw.Flush()
        sw.Close()

        ' Open the file to read from.
        Dim sr As StreamReader = File.OpenText(path)
        Dim s As String
        Do While sr.Peek() >= 0
            s = sr.ReadLine()
            Console.WriteLine(s)
        Loop
        sr.Close()

Open in new window

0
1030071002Author Commented:
is there any other way to write or append text in vb .net
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Jorge PaulinoIT Pro/DeveloperCommented:
>> is there any other way to write or append text in vb .net
What do you mean with that?
0
1030071002Author Commented:
other wise from using om_prakash_p method which he suggest using StreamWriter
Dim path As String = "c:\temp\MyTest.txt"
        Dim sw As StreamWriter
 
        ' This text is added only once to the file.
        If File.Exists(path) = False Then
            ' Create a file to write to.
            sw = File.CreateText(path)
 
            sw.WriteLine("Hello")
            sw.WriteLine("And")
            sw.WriteLine("Welcome")
            sw.Flush()
            sw.Close()
        End If
 
        ' This text is always added, making the file longer over time
        ' if it is not deleted.
        sw = File.AppendText(path)
        sw.WriteLine("This")
        sw.WriteLine("is Extra")
        sw.WriteLine("Text")
        sw.Flush()
        sw.Close()
 
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jorge PaulinoIT Pro/DeveloperCommented:
I also suggested a StreamWriter :)
You have other ways to do that, but you need that for?
You can use also:

My.Computer.FileSystem.WriteAllText("c:\myText.txt","some text",True) ' True = append method
IO.File.WriteAllText("c:\myText.txt", "some text")
0
1030071002Author Commented:
is this file system object

'loop to read & write to file
Using fs As New IO.FileStream(localFile, IO.FileMode.Create)
Dim buffer(2047) As Byte
Dim read As Integer = 0
Do
read = responseStream.Read(buffer, 0, buffer.Length)
fs.Write(buffer, 0, read)
Loop Until read = 0 'see Note(1)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.