Search code examples
c++special-folders

How to get the My Music as the default selected path in a Folder Selection dialog


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?


Solution

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

    should give the string value.