请教OPenFileDialog类的InitialDirectory属性中路径保持和恢复的问题 各位大侠,我知道在InitialDirectory中可以设置打开对话框的初始路径,但现在的问题是:我想让应用程序在没有关闭(也即程序一直在运行)的时候,让打开对话框能保持最近一次使用后的路径,但当应用程序关闭之后再次运行,打开对话框能恢复至InitialDirectory中所设置的值。请问该如何才能做到呢?PS:设置StoreDirectory属性没有用,我试过了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 做个变量记录 InitialDirectory 不就可以了? 嗯,谢谢,思路很好,可以借鉴。但实现起来有点复杂哦,.NET中有没有现成的方法或属性呢? private string Road = null; private void button7_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = "f:\\"; if (Road != null) { ofd.InitialDirectory = Road ; } if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.Text = ofd.FileName; Console.WriteLine(ofd.FileName); Road = ofd.FileName.Substring(0,ofd.FileName.LastIndexOf('\\')); Console.WriteLine(Road); } } 用个txt文件或者xml文件保存下 谢谢spmzfz提供的源码,懂了! 怎么获dataGridView中的数据 serialport接收数据用richTextBox显示问题 DataTable可增加计算列的问题(试图除以零) [集合问题] System.Collections名称空间 请教:如果得到异步调用后出现的异常 C# timer1 关于catch中再throw的问题 初来乍到,问个问题先 C#Winform窗体的,Access数据库,家庭财务管理系统 C#或者WPF 代码检测电脑上是否已经安装.net 4.0 环境?求解。。。 麻烦看下我这个接口例子哪里错了?~! 我想问问如何获取Oracle数据库的一些基本信息
private string Road = null;
private void button7_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = "f:\\";
if (Road != null) { ofd.InitialDirectory = Road ; }
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.Text = ofd.FileName;
Console.WriteLine(ofd.FileName); Road = ofd.FileName.Substring(0,ofd.FileName.LastIndexOf('\\'));
Console.WriteLine(Road);
}
}