How to save a file path as an AU/VST plugin parameter

This doesn’t work, at least in Reaper. But thanks for the hint.

So I didn’t figure out how to inform the DAW of the changes. I had to make a button to open the file in this way.

// PluginProcessor.cpp
AudioProcessor::AudioProcessor():
{
                 state (*this, nullptr, "state",
                 { /* other AudioParameters for controls */
                   std::make_unique<AudioParameterBool> ("ofile", "OpenFile", 0)
                   }),
}


// PluginEditor.cpp
AudioProcessorEditor::AudioProcessorEditor ():
{
    openButton.onClick = [this]
    {
        openButtonState.setValue(true);
    };

    openButtonState.setValue(false);
    openButtonState.addListener (this);
}

void AudioProcessorEditor::timerCallback()
{
    openButtonState.referTo (audioProcessor.state.getParameterAsValue ("ofile"));
}

void AudioProcessorEditor::valueChanged (Value& vChange)
{
    if(vChange == openButtonState && openButtonState.getValue())
    {
        openButtonState.removeListener(this);
        fileBrowser(); // your void
        openButtonState.setValue(false);
        openButtonState.addListener(this);
    }
}

private:
juce::TextButton openButton { "FILE" };
juce::Value openButtonState;