R
Robert Linder
I am trying to write
'StringWriter SW = new StringWriter();' to a FileStream.
The code writes the text to file, but NotePad does not see the NewLines.
Below is the code snippet taken from a large project
////////////// Main ////////////////////////////////////////
StringWriter DataWriter ;
this.FileOut = new FileStream( @"c:\RegChk.txt" ,FileMode.Create );
this.BinaryOut = new BinaryWriter( this.FileOut );
-------------------------------------------------------------------------
StringWriter SW = new StringWriter();
this.SetWriter(SW);
-------------------------------------------------------------------------
SW.Close();
StringBuilder bu = SW.GetStringBuilder();
string dataSW = bu.ToString() ;
// print only of there is data
if ( dataSW.Length.Equals(0).Equals(false) )
{
string rKeyString = "Registry Key '"+rkeyName+"'\n";
this.BinaryOut.Write( rKeyString);
this.BinaryOut.Write(dataSW);
this.BinaryOut.Write("\n");
this.BinaryOut.Flush();
}
====================================================================================
public void SetWriter( StringWriter dataOut )
{
try
{
if ( ! dataOut.Equals(null) )
{
this.DataWriter = dataOut;
}
}
catch( System.NullReferenceException )
{
// error
}
}
private void PrintData( string msg , string key , string data )
{
this.DataWriter.Write( msg );
this.DataWriter.Write( " '");
this.DataWriter.Write( key );
this.DataWriter.Write( "' '");
this.DataWriter.Write( data );
this.DataWriter.Write( "\n");
}
'StringWriter SW = new StringWriter();' to a FileStream.
The code writes the text to file, but NotePad does not see the NewLines.
Below is the code snippet taken from a large project
////////////// Main ////////////////////////////////////////
StringWriter DataWriter ;
this.FileOut = new FileStream( @"c:\RegChk.txt" ,FileMode.Create );
this.BinaryOut = new BinaryWriter( this.FileOut );
-------------------------------------------------------------------------
StringWriter SW = new StringWriter();
this.SetWriter(SW);
-------------------------------------------------------------------------
SW.Close();
StringBuilder bu = SW.GetStringBuilder();
string dataSW = bu.ToString() ;
// print only of there is data
if ( dataSW.Length.Equals(0).Equals(false) )
{
string rKeyString = "Registry Key '"+rkeyName+"'\n";
this.BinaryOut.Write( rKeyString);
this.BinaryOut.Write(dataSW);
this.BinaryOut.Write("\n");
this.BinaryOut.Flush();
}
====================================================================================
public void SetWriter( StringWriter dataOut )
{
try
{
if ( ! dataOut.Equals(null) )
{
this.DataWriter = dataOut;
}
}
catch( System.NullReferenceException )
{
// error
}
}
private void PrintData( string msg , string key , string data )
{
this.DataWriter.Write( msg );
this.DataWriter.Write( " '");
this.DataWriter.Write( key );
this.DataWriter.Write( "' '");
this.DataWriter.Write( data );
this.DataWriter.Write( "\n");
}