Verifica password dei file crittografati
Contents
[
Hide
]
Se i file Excel (xlsx, xlsb, xls, xlsm) e i file Open office (ODS) sono bloccati da password, Aspose supporta una semplice verifica della password senza l’analisi di dati specifici dei file.
Verifica la password del file crittografato
Per verificare la password del file crittografato, Aspose.Cells for .NET fornisce il metodo VerifyPassword. Questi metodi accettano due parametri: lo stream del file e la password da verificare. Il seguente frammento di codice dimostra l’uso del metodo VerifyPassword per verificare se la password fornita è valida o meno.
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); |