Method GetContentAsync
GetContentAsync(Encoding, CancellationToken)
Gets the text content of this resource asynchronously.
Content is cached after first load. Subsequent calls return the cached value.
public Task<string> GetContentAsync(Encoding encoding = null, CancellationToken cancellationToken = default)
Parameters
encodingEncodingThe encoding to use when reading the file. Defaults to UTF-8 if
null.cancellationTokenCancellationTokenA token to observe while waiting for the task to complete.
Returns
Examples
Asynchronously loading resource content:
var skill = AgentSkill.Load("./skills/api-designer");
var template = skill.GetResource("templates/openapi.yaml");
string content = await template.GetContentAsync();
Exceptions
- FileNotFoundException
Thrown when the resource file does not exist.
- IOException
Thrown when an I/O error occurs while reading the file.