Comment obtenir l'icône d'un fichier
Source / Exemple :
#region Using directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
#endregion
namespace ObtenirIcône
{
partial class Form1 : Form
{
private string title = " ...ObtenirIcône...";
private int count = 0;
private OpenFileDialog open1 = new OpenFileDialog();
public Form1()
{
InitializeComponent();
InitApp();
timer1.Start();
}
public void InitApp()
{
listView1.Items.Clear();
if (open1.ShowDialog() == DialogResult.OK && open1.FileName.Length > 0)
{
Icon ico = Icon.ExtractAssociatedIcon(open1.FileName);
pictureBox1.Image = ico.ToBitmap();
ImageList imageList = new ImageList();
imageList.Images.Add(ico);
imageList.ColorDepth = ColorDepth.Depth32Bit;
imageList.ImageSize = new Size(32, 32);
listView1.LargeImageList = imageList;
listView1.Items.Add(new ListViewItem("W@lid", 0));
}
}
[STAThread]
public static void Main()
{
Application.EnableRTLMirroring();
Application.EnableVisualStyles();
Application.Run(new Form1());
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Text = string.Concat(title.Substring(count));
if(count == title.Length)
{
count = 0;
}
else
{
count++;
}
}
private void button1_Click(object sender, EventArgs e)
{
InitApp();
}
}
}
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.