/ Published in: C#
This code enable you to have an OpenFileDialog that select directly all types of images.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
string filter = "Tous les fichiers image|"; ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); string sep = ""; bool isFirst = true; foreach (var c in codecs) { if (!isFirst) sep = ";"; filter = String.Format("{0}{1}{2}", filter, sep, c.FilenameExtension); isFirst = false; } filter += "|"; sep = string.Empty; foreach (var c in codecs) { string codecName = c.CodecName.Substring(8).Replace("Codec", "").Trim(); filter = String.Format("{0}{1}{2} ({3})|{3}", filter, sep, codecName, c.FilenameExtension); sep = "|"; } dlg.Filter = filter; Nullable<bool> result = dlg.ShowDialog(); if (result == true) { imageUri = dlg.FileName; }