我想從here獲取一個基本的文件對話框示例,並且在'OK'上出現錯誤,我不知道爲什麼。'System.Nullable <bool>'不包含'OK'的定義
錯誤1'System.Nullable'不包含'OK'的定義,並且沒有找到接受'System.Nullable'類型的第一個參數的擴展方法'OK'(您是否缺少using指令集引用?)
private void button1_Click(object sender, System.EventArgs e)
{
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
using (myStream)
{
// Insert code to read the stream here.
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
}
你打開文件對話框什麼組件可從? – 2010-08-17 15:06:15
這個工作,你可以更具體一點?錯誤可能不在這裏... – jeroenh 2010-08-17 15:06:22