代码之家  ›  专栏  ›  技术社区  ›  Oswald Umeh

Azure应用程序中的文件读取操作出现“找不到路径的一部分”错误

  •  3
  • Oswald Umeh  · 技术社区  · 8 年前

    我建立了一个ASP。NET核心api应用程序它部署到Azure web api应用程序。 在代码中,我尝试在某个点上读取content root中文件的内容,插入某些占位符作为其实际值。

    找不到路径的一部分。。。

    我得到的完整文件路径如下:

    Path.Combine(hostingEnvironment.ContentRootPath, "containing directory\filename")
    

    N、 B 我可以将此文件存储在Azure文件存储容器中,但我觉得读取它会太麻烦,再加上经常读取此文件的成本。

    1 回复  |  直到 8 年前
        1
  •  4
  •   Tom Sun    8 年前

    找不到路径的一部分。。。

    根据例外情况,它表示Azure中没有相关路径。如果可能的话,我们可以 remote debug Azure Web Apps . 然后我们可以得到文件路径。之后我们可以使用Azure kudu( https://yoursite.scm.azurewebsites.net )用于检查路径是否存在的工具。

    enter image description here

    如果文件路径不存在,我们可以直接将文件夹拖动到kudu工具,也可以使用Visual Studio发布文件夹。在那之后,它应该会起作用。

    enter image description here

    Azure Web App sandbox . 关于Azure网站文件结构,请参阅 document

    /
        LogFiles
            Application
                <instance>-<pid>-<ticks>.txt // application (nodejs/dotnet/php) traces
            DetailedError
                ErrorPage####.htm // error details
            Git
                trace
                    trace.xml // Trace generated during git deployments
                    <instance>-<guid>.txt // kudu related traces
                deployment
                    <instance>-<guid>.txt // deployment related traces
            http
                RawLogs
                    <logfile>.log     // iis http log. iis buffers and flushes every 60sec.
            W3SVC#####
                fr####.xml            // IIS fail request traces
                freb.xsl
        site
            wwwroot
                hello.htm             // The files that are live in your app
            repository                // Your repo, including working files (i.e. not bare)
                .git
                    HEAD, index and other git files
            deployments
                [commit id 1]
                    log.xml           // The deployment log, similar to what the protal shows
                    status.xml        // The status of the deployment (success/failure)
                    manifest          // The list of files that were deployed
                [commit id 2]
                    ...
        .ssh
            config                // This contains config to disable strict host checking
            id_rsa                // private key in PEM format
            known_hosts           // known hosts have been accepted
        Data
            Jobs
                Triggered
                    MyTriggeredJob1
                        20131112101559
                            output.log
                            error.log
                            status
    
                Continuous
                    MyContinuousJob1
                        job.log
                        status
        SiteExtensions
            // TODO: add details here