如何最后一个文件夹保存打开文件对话框? [英] How to save last folder in openFileDialog?

查看:199
本文介绍了如何最后一个文件夹保存打开文件对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让我的应用程序商店中的打开文件对话框打开最后一个路径和之后开盘恢复呢?



 打开文件对话框openFileDialog1 =新的OpenFileDialog(); 
openFileDialog1.Filter =TXT文件(* .txt)| * .TXT |所有文件(*。*)| *。*;
如果(openFileDialog1.ShowDialog()== DialogResult.OK)
{
acc_path = openFileDialog1.FileName;
Settings.Default.acc_path = acc_path;

的foreach(字符串s在File.ReadAllLines(openFileDialog1.FileName))
{
accs.Enqueue(S);
}
label2.Text = accs.Count.ToString();
}


解决方案

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


How do I make my application store the last path opened in openFileDialog and after new opening restore it?

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();
}

解决方案

This is the easiest way: FileDialog.RestoreDirectory.

这篇关于如何最后一个文件夹保存打开文件对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆