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

StackOverflow https://stackoverflow.com/questions/15167035

  •  16-03-2022
  •  | 
  •  

Pergunta

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?

Foi útil?

Solução

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

should give the string value.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top