Web服务 - Azure Cloud Service中找不到文件异常

问题描述 投票:1回答:1

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

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

        }

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

但是抛出了File not found异常

System.Web.Services.Protocols.SoapException: 'Server was unable to process request. ---> Could not find file 'D:\Windows\system32\vision.json'.'
c# .net azure web-services asmx
1个回答
0
投票

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

Environment.ExpandEnvironmentVariables(@"%HOME%\site\wwwroot\vision.json")
© www.soinside.com 2019 - 2024. All rights reserved.