Skip to content

Commit 8e307f3

Browse files
Merge pull request #323 from SyncfusionExamples/929658-compare
929658-Add sample Check-document-has-diff-after-compare
2 parents 592e385 + ae813ea commit 8e307f3

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35527.113 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Check-document-has-diff-after-compare", "Check-document-has-diff-after-compare\Check-document-has-diff-after-compare.csproj", "{C1DFB7E3-A672-48DA-8BE5-689EED49C966}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{C1DFB7E3-A672-48DA-8BE5-689EED49C966}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C1DFB7E3-A672-48DA-8BE5-689EED49C966}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C1DFB7E3-A672-48DA-8BE5-689EED49C966}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C1DFB7E3-A672-48DA-8BE5-689EED49C966}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Check_document_has_diff_after_compare</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\Original.docx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Data\Revised.docx">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIO;
3+
4+
namespace Check_document_has_diff_after_compare
5+
{
6+
internal class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
// Load the original and revised Word documents.
11+
using (FileStream originalStream = new FileStream(Path.GetFullPath(@"Data/Original.docx"), FileMode.Open, FileAccess.Read))
12+
using (FileStream revisedStream = new FileStream(Path.GetFullPath(@"Data/Revised.docx"), FileMode.Open, FileAccess.Read))
13+
{
14+
using (WordDocument originalDocument = new WordDocument(originalStream, FormatType.Docx))
15+
using (WordDocument revisedDocument = new WordDocument(revisedStream, FormatType.Docx))
16+
{
17+
// Configure comparison options to ignore formatting changes.
18+
ComparisonOptions compareOptions = new ComparisonOptions();
19+
compareOptions.DetectFormatChanges = false;
20+
21+
// Compare the documents.
22+
originalDocument.Compare(revisedDocument);
23+
24+
// Check if there are content differences.
25+
if (originalDocument.HasChanges)
26+
Console.WriteLine("Differences detected in the document content.");
27+
else
28+
Console.WriteLine("The documents have the same content.");
29+
30+
Console.ReadLine();
31+
}
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)