c# - Web 服务 - Azure 云服务中未找到文件异常
问题描述
我正在尝试使用网络方法读取文件
[WebMethod]
public string getjson()
{
string contents = File.ReadAllText("vision.json");
return contents;
}
我已经登录到 Azure 门户中提供的 ftp 帐户并上传了文件。
但是抛出了 File not found 异常
System.Web.Services.Protocols.SoapException: 'Server was unable to process request. ---> Could not find file 'D:\Windows\system32\vision.json'.'
解决方案
尝试使用 json 文件的完整路径。
Environment.ExpandEnvironmentVariables(@"%HOME%\site\wwwroot\vision.json")
推荐阅读
- python - 有 2 个独立的无限循环
- javascript - 我无法使用我的函数更改或更新变量
- android - 如何修复 build.gradle?
- node.js - 了解 TypeScript BotFramework 和 Emulator 之间的 HTTP 聊天
- javascript - 如何使用格式为 mm/dd/yyyy 的 Moment 添加天数
- python - 提高多标签文本分类的准确性
- c - 如何使用实际设备路径解析 USB 设备的 \\.\xxx 路径
- selenium - Selenium Grid:功能是否总是并行运行而场景总是串行运行?这是可定制的吗?
- excel - 创建动态验证列表
- java - 无法通过android studio连接天蓝色数据库