/// <summary> /// Gets a license key from the specified file. /// </summary> private static LicenseKey GetFromAssembly(String filename) { LicenseKey result; Assembly assembly = LicenseKey.GetEntryAssembly(); String resourceName = String.Format("{0}.{1}", assembly.GetName().Name, filename); using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) result = LicenseKey.GetFromText(reader.ReadToEnd()); return(result); }
/// <summary> /// Gets a license key from the specified file. /// </summary> private static LicenseKey GetFromFile(String filename) { LicenseKey result = null; // Validate that the key exists String asmbPath = Path.GetDirectoryName(LicenseKey.GetEntryAssembly().CodeBase.Substring(8)); String filePath = Path.Combine(asmbPath, filename); if (File.Exists(filePath)) { result = LicenseKey.GetFromText(File.ReadAllText(filePath)); } return(result); }