/// <summary> /// Gets the language string of the path specified using the format that the installer /// expects to find them in in the database. /// </summary> /// <param name="path">Path to the file</param> /// <returns>Language string in the form of a decimal language ID, or an empty string if the file /// does not contain a language ID</returns> /// <exception cref="FileNotFoundException">the file does not exist or could not be read</exception> /// <remarks><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msigetfileversion.asp">MsiGetFileVersion</a> /// </p></remarks> public static string GetFileLanguage(string path) { StringBuilder language = new StringBuilder("", 10); uint verBufSize = 0, langBufSize = 0; uint ret = NativeMethods.MsiGetFileVersion(path, null, ref verBufSize, language, ref langBufSize); if (ret == (uint)NativeMethods.Error.MORE_DATA) { language.Capacity = (int)++langBufSize; ret = NativeMethods.MsiGetFileVersion(path, null, ref verBufSize, language, ref langBufSize); } if (ret != 0 && ret != (uint)NativeMethods.Error.FILE_INVALID) { if (ret == (uint)NativeMethods.Error.FILE_NOT_FOUND || ret == (uint)NativeMethods.Error.ACCESS_DENIED) { throw new FileNotFoundException(null, path); } else { throw InstallerException.ExceptionFromReturnCode(ret); } } return(language.ToString()); }