diff --git a/Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not.sln b/Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected.sln similarity index 55% rename from Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not.sln rename to Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected.sln index f700b326..4bbbc018 100644 --- a/Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not.sln +++ b/Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.14.37012.4 d17.14 +VisualStudioVersion = 17.14.37411.7 d17.14 MinimumVisualStudioVersion = 10.0.40219.1 -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}" +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}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {54A935D7-C09A-697B-0D61-C7AAC43F2784}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {54A935D7-C09A-697B-0D61-C7AAC43F2784}.Debug|Any CPU.Build.0 = Debug|Any CPU - {54A935D7-C09A-697B-0D61-C7AAC43F2784}.Release|Any CPU.ActiveCfg = Release|Any CPU - {54A935D7-C09A-697B-0D61-C7AAC43F2784}.Release|Any CPU.Build.0 = Release|Any CPU + {14F884CF-1AC7-B41A-C300-C3991FDE4A7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {14F884CF-1AC7-B41A-C300-C3991FDE4A7F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {14F884CF-1AC7-B41A-C300-C3991FDE4A7F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {14F884CF-1AC7-B41A-C300-C3991FDE4A7F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {FCABE1DE-F4AA-4316-AEF1-3C5C985F9610} + SolutionGuid = {F71E08D4-7F59-4261-8BD3-E1D09BE390C0} EndGlobalSection EndGlobal diff --git a/Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not/Data/Template.docx b/Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected/Data/Template.docx similarity index 100% rename from Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not/Data/Template.docx rename to Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected/Data/Template.docx diff --git a/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 b/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 similarity index 100% rename from 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 rename 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 diff --git a/Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected/Program.cs b/Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected/Program.cs new file mode 100644 index 00000000..623d9cf5 --- /dev/null +++ b/Word-document/Identify-Word-document-is-Encrypted-or-Protected/.NET/Identify-Word-document-is-Encrypted-or-Protected/Program.cs @@ -0,0 +1,37 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using System; +using System.IO; + +namespace Identify_Word_document_is_Encrypted_or_Protected +{ + class Program + { + static void Main(string[] args) + { + // Load a Word document. + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + try + { + //Open the Word document using stream. + WordDocument document = new WordDocument(fileStream, FormatType.Docx); + ProtectionType protectionType = document.ProtectionType; + + if (protectionType != ProtectionType.NoProtection) + Console.WriteLine("The Word document is protected by " + protectionType.ToString()); + else + Console.WriteLine("The Word document is not protected."); + } + catch (Exception exception) + { + //Return if Word document is encrypted. + if (exception.Message == "Document is encrypted, password is needed to open the document") + { + Console.WriteLine("The Word document is encrypted, need password to open."); + } + } + } + } + } +} \ No newline at end of file diff --git a/Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not/Program.cs b/Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not/Program.cs deleted file mode 100644 index ea75bb26..00000000 --- a/Word-document/Identify-Word-document-is-Encrypted-or-not/.NET/Identify-Word-document-is-Encrypted-or-not/Program.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Syncfusion.DocIO; -using Syncfusion.DocIO.DLS; -using System; -using System.IO; - -namespace Identify_Word_document_is_Encrypted_or_not -{ - class Program - { - static void Main(string[] args) - { - //Creates a new Word document. - using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - Console.WriteLine(IsEncrypted(fileStreamPath)); - } - } - public static string IsEncrypted(FileStream fileStream) - { - try - { - //Open the existing Word document. - WordDocument document = new WordDocument(fileStream, FormatType.Docx); - return "Document is not encrypted."; - } - catch (Exception exception) - { - //Return if Word document is encrypted. - if (exception.Message == "Document is encrypted, password is needed to open the document") - { - return exception.Message; - } - } - return "Document is not encrypted."; - } - } -} \ No newline at end of file