gpt4 book ai didi

c# - 如何在 openFileDialog 中保存最后一个文件夹?

转载 作者:太空狗 更新时间:2023-10-29 17:30:37 24 4
gpt4 key购买 nike

如何让我的应用程序存储在 openFileDialog 中打开的最后一个路径,并在新打开后恢复它?

OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
acc_path = openFileDialog1.FileName;
Settings.Default.acc_path = acc_path;

foreach (string s in File.ReadAllLines(openFileDialog1.FileName))
{
accs.Enqueue(s);
}
label2.Text = accs.Count.ToString();
}

最佳答案

这是最简单的方法:FileDialog.RestoreDirectory .

关于c# - 如何在 openFileDialog 中保存最后一个文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16078362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com