Reputation: 73
FolderBrowserDialog openfolderdialog1 = new FolderBrowserDialog();
openfolderdialog1.SelectedPath = "..\\..\\Gambar Train\\";
if (openfolderdialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openfolderdialog1.SelectedPath;
}
It is not working. Do you have solution for this ? i want to use "..\.." cause the folder location is not fixed.
Upvotes: 0
Views: 4872
Reputation: 1491
As ..\ is a 'relative' path, you need to define what its relative to.
So "..\..\folder\" will work (your example isn't because SelectedPath
is a string), but you can't say 100% where that location will be.
I would look at things like the Directory.GetCurrentDirectory
or AppDomain.CurrentDomain.BaseDirectory
and base your location on that.
Upvotes: 0
Reputation: 161831
The SelectedPath
property is a string
, not a DirectoryInfo
.
Try
openfolderdialog1.SelectedPath = "..\\..\\Gambar Train\\";
Upvotes: 0
Reputation: 28413
Set the SelectedPath property before you call ShowDialog ...
folderBrowserDialog1.SelectedPath = @"c:\temp\";
folderBrowserDialog1.ShowDialog();
Will start them at C:\Temp
Upvotes: 1