Skip to content

Commit 90d2c74

Browse files
Added sample
1 parent 87b7556 commit 90d2c74

5 files changed

Lines changed: 44 additions & 44 deletions

File tree

Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not.sln renamed to Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected.sln

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.14.37012.4 d17.14
4+
VisualStudioVersion = 17.14.37411.7 d17.14
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Identify-Word-document-is-Encrypted-or-not", "Identify-Word-document-is-Encrypted-or-not\Identify-Word-document-is-Encrypted-or-not.csproj", "{54A935D7-C09A-697B-0D61-C7AAC43F2784}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Identify-Word-document-is-Encrypted-or-Protected", "Identify-Word-document-is-Encrypted-or-Protected\Identify-Word-document-is-Encrypted-or-Protected.csproj", "{14F884CF-1AC7-B41A-C300-C3991FDE4A7F}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{54A935D7-C09A-697B-0D61-C7AAC43F2784}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{54A935D7-C09A-697B-0D61-C7AAC43F2784}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{54A935D7-C09A-697B-0D61-C7AAC43F2784}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{54A935D7-C09A-697B-0D61-C7AAC43F2784}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{14F884CF-1AC7-B41A-C300-C3991FDE4A7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{14F884CF-1AC7-B41A-C300-C3991FDE4A7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{14F884CF-1AC7-B41A-C300-C3991FDE4A7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{14F884CF-1AC7-B41A-C300-C3991FDE4A7F}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {FCABE1DE-F4AA-4316-AEF1-3C5C985F9610}
23+
SolutionGuid = {F71E08D4-7F59-4261-8BD3-E1D09BE390C0}
2424
EndGlobalSection
2525
EndGlobal

Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not/Data/Template.docx renamed to Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected/Data/Template.docx

File renamed without changes.

Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not/Identify-Word-document-is-Encrypted-or-not.csproj renamed to Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected/Identify-Word-document-is-Encrypted-or-Protected.csproj

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using System;
4+
using System.IO;
5+
6+
namespace Identify_Word_document_is_Encrypted_or_Protected
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
// Load a Word document.
13+
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
14+
{
15+
try
16+
{
17+
//Open the Word document using stream.
18+
WordDocument document = new WordDocument(fileStream, FormatType.Docx);
19+
ProtectionType protectionType = document.ProtectionType;
20+
21+
if (protectionType != ProtectionType.NoProtection)
22+
Console.WriteLine("The Word document is protected by " + protectionType.ToString());
23+
else
24+
Console.WriteLine("The Word document is not protected.");
25+
}
26+
catch (Exception exception)
27+
{
28+
//Return if Word document is encrypted.
29+
if (exception.Message == "Document is encrypted, password is needed to open the document")
30+
{
31+
Console.WriteLine("The Word document is encrypted, need password to open.");
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}

Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not/Program.cs

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)