コード例 #1
0
        public bool LoadLicenseFromFile(string filename)
        {
            FileStream fs = null;

            try
            {
                if (!File.Exists(filename))
                {
                    return(false);
                }

                fs = File.OpenRead(filename);
                if (fs.Length > MaxFileSize)
                {
                    throw new Exception("Invalid length of license file");
                }

                TextReader tr            = new StreamReader(fs);
                string     licenseBase64 = tr.ReadToEnd();
                fs.Close();

                _licenseData = ObjectSerializer.DeserializeLicenseDataFromString(licenseBase64);

                _serviceState.Valid     = false;
                _serviceState.Validated = false;

                return(_licenseData != null);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "LoadLicenseFromFile");
            }
            finally
            {
                fs?.Close();
            }

            return(false);
        }