I have added an OpenFileDialog
to my button (called "Browse") press event that should open a dialog, get a file name and return it to me.
using System;
using System.IO;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string lastFileOpenPath = "";
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.Title = "Please choose the file";
ofd.InitialDirectory = (Directory.Exists(lastFileOpenPath) ? lastFileOpenPath : @"C:\");
string archiveExt = "";
for (int cn = 1; cn <= 50; cn++)
archiveExt += (archiveExt == "" ? "" : ";") + "*." + cn.ToString().PadLeft(3, '0');
ofd.Filter = "Archive File (*.rar)|*.rar|Archive Files (*.###)|" + archiveExt + "|All Supported Files (*.rar, *.###)|" + archiveExt + ";*.rar";
ofd.FilterIndex = 3;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK && File.Exists(ofd.FileName))
{
FilePath.Text = ofd.FileName;
lastFileOpenPath = Path.GetDirectoryName(FilePath.Text);
}
}
}
}
}
For some reason any time I press my Browse
button (even if I do nothing and hit cancel) and then try to close the form that's open, I get the following message in the Output
window. The message does not appear if I open the form, then close it. It does appear if I open the form, click the Browse button, hit cancel and then close the form.
Assertion failed: Successful WSASTARTUP not yet performed (........\src\signaler.cpp:194)
Is it possible to account for this so the "error" (if it is an error) does not appear in the Output
window? I'm not asking because it's annoying, I could care less of the message in a debug output window. I'm asking because of optimization.