Determining if the License is loaded successfully

C# code to determine if the License is loaded successfully

The following code accesses the Workbook.IsLicensed property before setting a license and it returns false. Then it loads the license and accesses the property again which now returns true.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the License File
string licPath = @"Aspose.Cells.lic";
// Create workbook object before setting a license
Workbook workbook = new Workbook();
// Check if the license is loaded or not. It will return false
Console.WriteLine(workbook.IsLicensed);
try
{
Aspose.Cells.License lic = new Aspose.Cells.License();
lic.SetLicense(licPath);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// Check if the license is loaded or not. Now it will return true
Console.WriteLine(workbook.IsLicensed);

Console Output

Here is the console (debug) output of the above sample code

False

True