关于catch(IOException e)的弱智问题,有分!
一个窗体中有一个button1按钮,click时间如下,可是当E:\\Directory目录下没有内容时无法捕捉到异常,为什么呢?请高手指点!
private void button1_Click(object sender, System.EventArgs e)
{
string[] i;
try
{
i=System.IO.Directory.GetDirectories("E:\\Directory");
}
catch(IOException ioe)
{
string chr1;
chr1=System.Convert.ToString(ioe) ;
MessageBox.Show("错误:" + chr1,"显示信息",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
MessageBox.Show(i[0],"显示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}