DesktopAnalytics.Analytics.TryGetSettingsLocationInfoFromEntryAssembly C# (CSharp) Method

TryGetSettingsLocationInfoFromEntryAssembly() private method

private TryGetSettingsLocationInfoFromEntryAssembly ( string &settingsLocation, string &softwareName ) : bool
settingsLocation string
softwareName string
return bool
		private bool TryGetSettingsLocationInfoFromEntryAssembly(out string settingsLocation, out string softwareName)
		{
			settingsLocation = null;
			softwareName = null;

			var entryAssembly = Assembly.GetEntryAssembly(); // the main exe assembly
			if (entryAssembly == null) // Called from unmanaged code?
				return false;
			softwareName = Path.GetFileNameWithoutExtension(entryAssembly.Location);
			AssemblyCompanyAttribute companyAttribute = Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
			if (companyAttribute == null || string.IsNullOrEmpty(softwareName))
				return false;
			string companyName = companyAttribute.Company;
			if (companyName == null)
				return false;
			settingsLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
				companyName);
			return true;
		}