CommonOpenFileDialog opens again after has file chosen

774 views Asked by At
CommonOpenFileDialog cicon = new CommonOpenFileDialog();
        cicon.IsFolderPicker = false;
        cicon.Title = "Choose Icon";
        cicon.Filters.Add(new CommonFileDialogFilter("Executable Files", "*.exe"));
        cicon.Filters.Add(new CommonFileDialogFilter("Icon Files", "*.ico*"));
        if (cicon.ShowDialog() == CommonFileDialogResult.Ok)
        {
            try
            {
                Image fico = System.Drawing.Icon.ExtractAssociatedIcon(cicon.FileName).ToBitmap();
                metroTextBox1.Icon = fico;
            }
            catch (Exception re)
            {
                winmsg msg = new winmsg();
                msg.Title = "Icon Error -  Cannot find any Icon";
                msg.Content = "Path: " + re.Message;
                msg.ShowDialog();
                msg.Dispose();
            }
        }
        else
        {
            return;
        }

I am getting Open file dialog after file chosen, What could be the issue? Above code for click on CustomButton in Metrotextbox.

0

There are 0 answers