C
C#5d ago
armoire

✅ calling ShowDialog() with the OpenFolderDialog class creates an error

The error
System.ArgumentException
HResult=0x80070057
Message=Value does not fall within the expected range.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
System.ArgumentException
HResult=0x80070057
Message=Value does not fall within the expected range.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
my code :
C#
OpenFolderDialog getBaseDir = new OpenFolderDialog
{
Multiselect = false,
DefaultDirectory = userDir,
InitialDirectory = docsDir
};

bool? hasChosenAFolder = getBaseDir.ShowDialog();
C#
OpenFolderDialog getBaseDir = new OpenFolderDialog
{
Multiselect = false,
DefaultDirectory = userDir,
InitialDirectory = docsDir
};

bool? hasChosenAFolder = getBaseDir.ShowDialog();
The last line generates the error
4 Replies
armoire
armoireOP5d ago
UPDATE : apparently the problems was with userDir and docsDir Their definition :
C#
string userDir = "@" + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string docsDir = "@" + Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
C#
string userDir = "@" + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string docsDir = "@" + Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
I suppose the '@' wasn't appreciated
Buddy
Buddy5d ago
$close
MODiX
MODiX5d ago
If you have no further questions, please use /close to mark the forum thread as answered
armoire
armoireOP5d ago
My bad

Did you find this page helpful?