How to Read Embedded Files
Embedding Files
You can import a ready-made example from here: https://eu.eyeauras.net/share/S20250309131425bvdreSJs6IeI
How is it useful?
- custom configuration files
- some documentation for your program
- JavaScript files which will be loaded in your UI
- custom CSS files
Example
- Create an aura.
- Add a
C# Scriptaction toOn Enter. - Copy and paste the script itself.
- Create a new Markdown file, name it README
- Run the script.
- The script will print list of embedded files (in this case, only README.md) and README content
Script.csx
Log.Info("Hello, World!");
//built-in FileProvider which allows to access script environment files
var fileProvider = GetService<EyeAuras.Repl.IScriptFileProvider>();
var files = fileProvider.GetDirectoryContents("/");
Log.Info($"Script files:\n\t{files.DumpToTable()}");
var readmeContent = fileProvider.ReadAllText("README.md"); //or fileProvider.GetFileInfo() to get access to raw data
Log.Info($"README:\n{readmeContent}");
README.md
any text