Question

When opening a folder selection dialog in C++, I'm trying to get the default selected path to be %USERPROFILE%/My Music, but I can't figure that out.

this->diaActionFolder->SelectedPath = System::Environment::SpecialFolder::MyMusic;

The above code results in this error -

error C2664: 'System::Windows::Forms::FolderBrowserDialog::SelectedPath::set' : cannot convert parameter 1 from 'System::Environment::SpecialFolder' to 'System::String ^'

I guess that means that System::Environment::SpecialFolder::MyMusic is not a string (so presumably it is an object?). In that case, how can I extract the path from it so that I can set it as the default SelectedPath?

Was it helpful?

Solution

Environment::GetFolderPath(System::Environment::SpecialFolder::MyMusic)

should give the string value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top