我在textbox
其中保存和编码数据:select
path
.txt
SqlConnection
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);
}
textBox5.Text = string.Format("{0}", openFileDialog1.FileName) ;
// here I need some miracle to save default text for textBox5, appconfig maybe? according to which path was selected
nacti_spojeni();
}
但问题是用户每次要连接到 SQL 数据库时都必须选择路径,我认为如果可能的话,有办法将路径保存到应用程序配置中吗?我想到的其他事情是为文本框设置默认文本值。也许这是一个微不足道且毫无意义的问题。谢谢大家的时间。