The file dialog should open the last directory location that was used before it was closed, but I have no idea how to do this. My colleague only shows me an example of a word, when you click "file", it shows the last used files, he told me to use a register or INI file, which I had never used before.
Here is the code I'm using:
string f_sOudeLocatie = @"D:\path\is\classified"; private void btBrowse_Click(object sender, EventArgs e) { OpenFileDialog fdlg = new OpenFileDialog(); fdlg.Title = "Zoek de CSV file"; fdlg.InitialDirectory = f_sOudeLocatie; fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"; fdlg.FilterIndex = 1; fdlg.RestoreDirectory = true; if (fdlg.ShowDialog() == DialogResult.OK) { tbGekozenBestand.Text = fdlg.FileName; tbVeranderNaamIn.Text = Path.GetDirectoryName(fdlg.FileName); f_sOudeLocatie = Path.GetDirectoryName(fdlg.FileName); f_sSourceFileName = fdlg.FileName; f_sDestFileName = Path.GetFileName(Path.GetDirectoryName(fdlg.FileName)) + ".csv"; btOpslaan.Enabled = true; tbVeranderNaamIn.ReadOnly = false; } }
source share