c# - StringTemplate:从磁盘加载模板?

标签 c# .net stringtemplate

我在 C# 中使用 StringTemplate 并遵循代码从我的应用程序的子目录加载模板。

StringTemplateGroup group = new StringTemplateGroup("myGroup", "/tmp");
StringTemplate query = group.GetInstanceOf("Sample");
query.SetAttribute("column", "name");
Console.WriteLine(query);

我的应用程序的 tmp 目录中有一个模板文件 Sample.st。

我收到以下错误。

Unhandled Exception: System.ArgumentException: Can't find template Sample.st; group hierarchy is [myGroup]

有谁知道这里出了什么问题吗?

最佳答案

或许您应该将绝对路径指定为 StringTemplateGroup 构造函数的第二个参数?

关于c# - StringTemplate:从磁盘加载模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3024164/

相关文章:

c# - 从非 UI 线程访问 UI 元素

C# 在 TCP 上读取数据并不总是读取所有数据

c# - 将业务规则放入存储库中

c# - 为什么不抛出这个异常?

c# - 正则表达式匹配除

c# - 如何继续从命名管道/流发送/读取消息

c# - 为什么 Int16 变量减去 Int16 参数的结果是 Int32?

python - 使用字符串模板在python中制作quine?

translation - 在基本操作中分解表达式:ANTLR + StringTemplate

python - 如何将 StringTemplate 引擎集成到 CherryPy Web 服务器中