I saved the PowerPoint presentation as .ppt and .pptx with and without the password required to open them, opened them in 7-Zip and came to the preliminary conclusion that
- .pptx files without a password always use the standard .zip file format.
- .ppt files CompoundDocuments
- .pptx CompoundDocuments
- CompoundDocuments * Encrypt *
, NuGet OpenMcdf. #, CompoundDocuments.
using OpenMcdf;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace _22916194
{
class Program
{
static void Main(string[] args)
{
foreach (var file in args.Where(File.Exists))
{
switch (Path.GetExtension(file))
{
case ".ppt":
case ".pptx":
Console.WriteLine($"* {file} " + (HasPassword(file) ? "is " : "isn't ") + "passworded");
Console.WriteLine();
break;
default:
Console.WriteLine($" * Unknown file type: {file}");
break;
}
}
Console.ReadLine();
}
private static bool HasPassword(string file)
{
try
{
using (var compoundFile = new CompoundFile(file))
{
var entryNames = new List<string>();
compoundFile.RootStorage.VisitEntries(e => entryNames.Add(e.Name), false);
foreach (var entryName in entryNames)
{
if (entryName.Contains("Encrypt"))
return true;
}
compoundFile.Close();
}
}
catch (CFFileFormatException) {
return false;
}
return false;
}
}
}
Office. , , CompoundDocument, , * Encrypt * ( .doc , , ).