Get Script to Read from Folder in Theme Images

Posts: 72
So I want a script to read from a CarNum folder in my theme. It's a script to hide the carnum data binding if a dynamic image is found. I cannot for the life of me figure out how to get it to read that the path exists.

Here's the code:
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Results;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;

namespace Scripts
{
public class CarNumScript : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
if (value == null)
return null;
// Get the label running this converter script
// This label is showing the dynamic image
var label = item as Label;
if (label == null)
return null;

string path = @"assets/CarNum" + value + ".png";

if (System.IO.File.Exists(path))
{
// Send transparent as output
return Colors.Transparent;
}

else
{
if (parameter == "font")
return Colors.White;
return Colors.Black;
}
}
}
}


Any help is appreciated!
Posts: 72
Bumping this, really important for us to get this working so we can have more freedom when configuring our overlay for new customers.
Posts: 785
You can use the GetAbsolutePath on the DynamicBackground, assuming you configured your label to show the right dynamic image:
var path = label.DynamicBackground.GetAbsolutePath(item.Theme);


This path would resolve to the full path of the file. You can then check if it exists like you are already doing.
Posts: 72
Thanks Nick, got it finally working!