I'm relatively inexperienced with C++ and I'm currently creating a simple Windows Forms project. The following code is providing a strange error that I just can't wrap my head around.
if (folderBrowserDialog1->ShowDialog() == ::DialogResult::OK) {
String filepath = folderBrowserDialog1->SelectedPath;
for (auto& p : std::filesystem::directory_iterator(filepath)) {
// read files from filepath
}
}
The error, "no suitable user-defined conversion from System::String ^ to System::String exists" is referring to the folderBrowserDialog1->SelectedPath line. Despite the docs I've checked stating that SelectedPath is a string, apparently it's not the same type of string as C++ is expecting? I assume I need to do some kind of conversion but I'm at a total loss as to how I should do that as I really assumed that SelectedPath would be a regular String.