Currently, our app doesn’t support files that are protected by Azure/Microsoft Information Protection (https://learn.microsoft.com/en-us/azure/information-protection/what-is-information-protection). I want to inform the user that our app doesn’t support these files or give them a warning that functionalities are more limited.
I have found one way to peek if the file is protected here: https://learn.microsoft.com/en-us/information-protection/develop/quick-app-initialization-csharp
Although this could work, it is too much overhead to configure this approach.
Is there a fast, simple clean way to know that a file is protected by Azure/Microsoft Information Protection?
For Word, Excel and PowerPoint documents, I could try to open these files as ZIP files (because Office document files are ZIP files) and look for an ‘EncryptedPackage’ file in the root folder. But maybe there is a more conventional way.
2
Answers
For Word, Excel and PowerPoint documents we can zip and unzip files using
System.IO.Compression
Zip file:
Unzip Files:
Snippet for Encryption and Decryption of text
Encryption Code:
For File protection need to use the below namespace
WorkbookObject.Password = password;
WorkbookObject.SaveAs("FileName.xls")
for more information on file protection use this link
I was also looking for the solution to this .
I found following links helpful:
https://learn.microsoft.com/en-us/information-protection/develop/concept-mip-metadata
https://learn.microsoft.com/en-us/information-protection/develop/concept-mip-metadata#contentbits
We use apache tika as parser, through OOXMLParser we get the metadata of the file.
As per the documentation :