c# - 从当前项目文件夹加载文件
问题描述
我正在尝试加载 json 文件,同时在测试项目中模拟 api 以进行测试。模拟将加载 json。
我目前正在使用File.ReadAllText
,我尝试了以下
System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory.ToString(), "bank_response.json")
System.IO.Path.GetFullPath(Directory.GetCurrentDirectory() + @"\bank_response.json");
我得到了 bin 或 null 的路径。
解决方案
推荐阅读
- java - 如何将多页列的列中的值添加到数组中?
- vue.js - 是否可以基于布尔表达式将类绑定到元素?
- npm - npm installaton 停止在“正在启动'create theme.config'...”
- angular - 如何正确退订这种可观察的
- ios - CATextLayer foregroundColor 动画不适用于 iOS9 但适用于 iOS10 或更高版本
- javascript - React 无法为单选按钮设置值
- spring-boot - C# 中的属性 DisplayName 在 Spring boot (thymeleaf) 中应用
- javascript - 具有默认值的 Javascript 工厂模式,不起作用
- node.js - 使用nodejs在mongo中动态查询
- python - 读取保存在 Jupyter 文件夹中的 Excel 文件