Web服务-Azure云服务中未找到文件异常

时间:2019-03-05 09:16:01

标签: c# .net azure web-services asmx

我正在尝试使用网络方法读取文件

  [WebMethod]
        public string getjson()
        {
            string contents = File.ReadAllText("vision.json");
            return contents;

        }

我已经登录到Azure门户中提供的ftp帐户并上传了文件。 enter image description here

但是未找到文件异常

System.Web.Services.Protocols.SoapException: 'Server was unable to process request. ---> Could not find file 'D:\Windows\system32\vision.json'.'

1 个答案:

答案 0 :(得分:1)

尝试使用json文件的完整路径。

Environment.ExpandEnvironmentVariables(@"%HOME%\site\wwwroot\vision.json")