Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

Set the SelectedPath property before you call ShowDialog ...

folderBrowserDialog1.SelectedPath = @"c:\temp\";
folderBrowserDialog1.ShowDialog();

Will start them at C:\Temp

SelectedPath Property

The SelectedPath property is a string, not a DirectoryInfo.

Try

openfolderdialog1.SelectedPath = "..\\..\\Gambar Train\\";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top