暗号化ファイルのパスワードを確認する
Contents
[
Hide
]
Excel (xlsx、xlsb、xls、xlsm) および Open Office (ODS) ファイルがパスワードでロックされている場合、Aspose は、ファイルの特定のデータを解析することなく、単純なパスワード検証をサポートします。
暗号化されたファイルのパスワードを確認する
暗号化されたファイルのパスワードを確認するには、Aspose.Cells for .NET を指定します。パスワードを照合します方法。これらのメソッドは、検証が必要なファイル ストリームとパスワードの 2 つのパラメータを受け入れます。 次のコード スニペットは、パスワードを照合します提供されたパスワードが有効かどうかを検証するメソッド。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
// Create a Stream object | |
FileStream fstream = new FileStream(dataDir + "EncryptedBook1.xlsx", FileMode.Open); | |
bool isPasswordValid = FileFormatUtil.VerifyPassword(fstream, "1234"); | |
Console.WriteLine("Password is Valid: " + isPasswordValid); |