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?

有帮助吗?

解决方案

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

should give the string value.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top