如何检测文件格式并检查文件是否已加密

Contents
[ ]

以下示例代码说明如何通过文件路径检测文件格式并检查其扩展名。您还可以确定该文件是否已加密。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//Detect file format
FileFormatInfo info = FileFormatUtil.DetectFileFormat(dataDir + "Book1.xlsx");
//Gets the detected load format
Console.WriteLine("The spreadsheet format is: " + FileFormatUtil.LoadFormatToExtension(info.LoadFormat));
//Check if the file is encrypted.
Console.WriteLine("The file is encrypted: " + info.IsEncrypted);