What's Changed?
CompareStreams Method (CompareLogic)
Example 



KellermanSoftware.WhatsChanged Namespace > CompareLogic Class : CompareStreams Method
The original stream
The changed stream
The file or other name of the original stream
The file name or other name of the changed stream
Compare two text streams line by line
Syntax
Public Function CompareStreams( _
   ByVal originalStream As Stream, _
   ByVal changedStream As Stream, _
   ByVal originalName As String, _
   ByVal changedName As String _
) As ComparisonResult
Dim instance As CompareLogic
Dim originalStream As Stream
Dim changedStream As Stream
Dim originalName As String
Dim changedName As String
Dim value As ComparisonResult
 
value = instance.CompareStreams(originalStream, changedStream, originalName, changedName)
public ComparisonResult CompareStreams( 
   Stream originalStream,
   Stream changedStream,
   string originalName,
   string changedName
)

Parameters

originalStream
The original stream
changedStream
The changed stream
originalName
The file or other name of the original stream
changedName
The file name or other name of the changed stream

Return Value

A result of the comparison
Example
CompareLogic compareLogic = new CompareLogic(); //Trial Mode
//CompareLogic compareLogic = new CompareLogic("place user name here", "place license key here"); //License Mode
 
//Compare two strings
File.WriteAllText("original.txt", "This line was deleted.\r\nThis line is the same.\r\nThis line is a changed.");
File.WriteAllText("changed.txt", "This line is the same.\r\nThis line was changed.\r\nThis line was added.");
 
ComparisonResult result;
 
using (FileStream originalStream = new FileStream("original.txt", FileMode.Open, FileAccess.Read))
{
    using (FileStream changedStream = new FileStream("changed.txt", FileMode.Open, FileAccess.Read))
    {
        result = compareLogic.CompareStreams(originalStream, changedStream,"original.txt", "changed.txt");
    }
}
 
 
//Output to HTML, also can export to CSV, or DataTable
OutputHtmlLogic outputLogic = new OutputHtmlLogic();
outputLogic.OutputToFile(result, "CompareStreamsTest.html");
 
//Show the file in the browser
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "CompareStreamsTest.html";
proc.Start();
Dim compareLogic As New CompareLogic() 'Trial Mode
'Dim compareLogic As New CompareLogic("place user name here", "place license key here") 'License Mode
 
'Compare two strings
File.WriteAllText("original.txt", "This line was deleted." & vbCrLf & "This line is the same." & vbCrLf & "This line is a changed.")
File.WriteAllText("changed.txt", "This line is the same." & vbCrLf & "This line was changed." & vbCrLf & "This line was added.")
 
Dim result As ComparisonResult
 
Using originalStream As New FileStream("original.txt", FileMode.Open, FileAccess.Read)
    Using changedStream As New FileStream("changed.txt", FileMode.Open, FileAccess.Read)
        result = compareLogic.CompareStreams(originalStream, changedStream,"original.txt", "changed.txt")
    End Using
End Using
 
'Output to HTML, also can export to CSV, or DataTable
Dim outputLogic As New OutputHtmlLogic()
outputLogic.OutputToFile(result, "CompareStreamsTest.html")
 
'Show the file in the browser
Dim proc As New System.Diagnostics.Process()
proc.StartInfo.FileName = "CompareStreamsTest.html"
proc.Start()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

CompareLogic Class
CompareLogic Members