Skip to content

Receiving a filename

BarRaider edited this page Mar 24, 2021 · 1 revision

The Stream Deck SDK automatically appends a C:\fakepath\ to each file chosen from the Property Inspector's file picker. StreamDeck-Tools can also auto-populate that field, by adding an additional attribute named FilenameProperty to your property:

private class PluginSettings
{
    [FilenameProperty]
    [JsonProperty(PropertyName = "title")]
    public String Title { get; set; }
}

This will tell the AutoPopulateSettings method to strip the "C:\fakepath" from the input. But how do you make sure it shows correctly in the PropertyInspector too? Make sure you SAVE the settings back after StreamDeck-Tools fixes the filename:

public async override void ReceivedSettings(ReceivedSettingsPayload payload) 
{
    Tools.AutoPopulateSettings(settings, payload.Settings);
    // Return fixed filename back to the Property Inspector
    await Connection.SetSettingsAsync(JObject.FromObject(settings));
}