TextWriter vs. StreamWriter

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am using this operation to write a string variable response to a *.csv file. It runs into some problem: information gets lost about 50% of the time.
using ( StreamWriter sw = new StreamWriter ( pathq ) )
            {
                sw.Write ( response );
            }
I figured that this is perhaps due to the fact that this class is not thread safe. Another class
TextWriter is offered as a substitute however when I change the code above into:
using ( TextWriter sw = new TextWriter ( pathq ) )
            {
                sw.Write ( response );
            }
I get an error:
Error 1  Cannot create an instance of the abstract class or interface System.IO.TextWriter D:VCsharp_ProjectstapTCPports_1Class2.cs 127 37 tapTCPports_1
Why?
I posted the same question as a part of another thread here but it got very long already and I am afraid this question wont get due attention.
Thanks.

 
 

View the full article
 
Back
Top