【发布时间】:2017-10-21 21:02:23
【问题描述】:
对于一个学校项目,我不允许使用存储过程来存储我的 SQL 脚本。为了解决这个问题,我尝试在我的班级程序集中创建一个 SQL_scripts 文件夹。
现在我不知道如何从相对路径读取我的脚本?
这是我尝试但没有成功的:
var appDomain = System.AppDomain.CurrentDomain;
var basePath = appDomain.RelativeSearchPath ?? appDomain.BaseDirectory;
string path = Path.Combine(basePath, "SQL_scriptes", "GetAllEmptyRoomsAtDateRange.sql");
string query = File.ReadAllText(path);
但我总是在以下文件夹中:
- MyProject\Tests\bin\Debug\SQL_scriptes\GetAllEmptyRoomsAtDateRange.sql
有什么想法吗?
【问题讨论】:
标签: c# .net dll reflection