private void Image2Icon(string fileName, string targetFileName){ //Creats filename with ico extention string newFileName = Path.ChangeExtension(targetFileName, ".ico"); //Getting the Icon from the Filename using (Icon icon = Icon.ExtractAssociatedIcon(fileName)) { //Creating the Icon file and Writing the content using (Stream stream = File.Create(newFileName)) { icon.Save(stream); } }}