private void locbtn_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Title = "Select Folder";
openFileDialog1.InitialDirectory = @"C:\";//--"C:\\";
openFileDialog1.ValidateNames = false;
openFileDialog1.CheckFileExists = false;
openFileDialog1.CheckPathExists = true;
openFileDialog1.ShowDialog();
if (openFileDialog1.FileName != "")
{
textBox1.Text = openFileDialog1.FileName;
}
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
}
else
{
textBox1.Text = "Please Select an Another Folder!";
}
}
这是密码。当我单击locbtn时它应该显示,但它似乎拒绝了。
这段代码审核了2天,能给予我一个答复吗?我尝试了多个网站的(+ Youtube)源代码,和...什么都没发生我也试过FolderBrowserDialog,但没有任何变化。
1条答案
按热度按时间mf98qq941#
我将重新排列代码,以便您可以确定发生了什么。您的代码有两个
openFileDialog.ShowDialog()
语句。很可能错过了返回ShowDialog()
。尝试类似于: