Hi!
I'm looking for a solution too which can help me to compare two word documents using C#. For the moment I compare the two documents only by strings(I mean, only by the text content) but they could also have different styles, font sizes, images... Can we compare those 2 docs by bytes? It will be OK?
/// <summary>
/// Converts the content of a Word document to a string.
/// </summary>
/// <param name="document"></param>
/// <returns></returns>
public static string ConvertDocToString(Word.Document document)
{
string myLocalString = String.Empty;
try
{
myLocalString = document.Content.Text;
}
catch (Exception ex)
{
OfficeLibraryUtils.logger.Error(ex);
OfficeLibraryUtils.HandleException(ex);
}
return myLocalString;
}
public static bool AreTheSame(string string1, string string2)
{
// If CompareTo returns diff from 0, then the 2 strings are different.
return (string1.CompareTo(string2) == 0);
}
Thanks in advance,
Nicu
|