private void InjectIcon() { var targetPortableExecutable = new PortableExecutable(TargetFilePath); var targetIconResourceIdentifiers = targetPortableExecutable.GetResourceIdentifiers() .Where(r => r.Type.Code == ResourceType.Icon.Code || r.Type.Code == ResourceType.IconGroup.Code) .ToArray(); var appHostPortableExecutable = new PortableExecutable(AppHostFilePath); appHostPortableExecutable.RemoveIcon(); if (targetIconResourceIdentifiers.Any()) { foreach (var identifier in targetIconResourceIdentifiers) { appHostPortableExecutable.SetResource( identifier, targetPortableExecutable.GetResource(identifier).Data ); } Log.LogMessage("Injected icon into '{0}'.", AppHostFileName); } else { Log.LogMessage("Could not find icon resources in '{0}'.", TargetFileName); } }