What's Changed?
CompareFiles Method (CompareLogic)
Example 



KellermanSoftware.WhatsChanged Namespace > CompareLogic Class : CompareFiles Method
The original text file
The changed text file
Compare two text files line by line and return the differences
Syntax
Public Function CompareFiles( _
   ByVal originalFilePath As String, _
   ByVal changedFilePath As String _
) As ComparisonResult
Dim instance As CompareLogic
Dim originalFilePath As String
Dim changedFilePath As String
Dim value As ComparisonResult
 
value = instance.CompareFiles(originalFilePath, changedFilePath)
public ComparisonResult CompareFiles( 
   string originalFilePath,
   string changedFilePath
)
public:
ComparisonResult^ CompareFiles( 
   String^ originalFilePath,
   String^ changedFilePath
) 

Parameters

originalFilePath
The original text file
changedFilePath
The changed text file

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 = compareLogic.CompareFiles("original.txt", "changed.txt");
 
//Output to HTML, also can export to CSV, or DataTable
OutputHtmlLogic outputLogic = new OutputHtmlLogic();
outputLogic.OutputToFile(result, "CompareFilesTest.html");
 
//Show the file in the browser
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "CompareFilesTest.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 = compareLogic.CompareFiles("original.txt", "changed.txt")
 
'Output to HTML, also can export to CSV, or DataTable
Dim outputLogic As New OutputHtmlLogic()
outputLogic.OutputToFile(result, "CompareFilesTest.html")
 
'Show the file in the browser
Dim proc As New System.Diagnostics.Process()
proc.StartInfo.FileName = "CompareFilesTest.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