<tfoot id='bsWoj'></tfoot>

<i id='bsWoj'><tr id='bsWoj'><dt id='bsWoj'><q id='bsWoj'><span id='bsWoj'><b id='bsWoj'><form id='bsWoj'><ins id='bsWoj'></ins><ul id='bsWoj'></ul><sub id='bsWoj'></sub></form><legend id='bsWoj'></legend><bdo id='bsWoj'><pre id='bsWoj'><center id='bsWoj'></center></pre></bdo></b><th id='bsWoj'></th></span></q></dt></tr></i><div id='bsWoj'><tfoot id='bsWoj'></tfoot><dl id='bsWoj'><fieldset id='bsWoj'></fieldset></dl></div>

    • <bdo id='bsWoj'></bdo><ul id='bsWoj'></ul>

    1. <legend id='bsWoj'><style id='bsWoj'><dir id='bsWoj'><q id='bsWoj'></q></dir></style></legend>

      <small id='bsWoj'></small><noframes id='bsWoj'>

    2. 是否可以从存在 Azure 函数的同一文件夹中读取文件

      时间:2023-10-05

          <tbody id='V7u1A'></tbody>
      • <small id='V7u1A'></small><noframes id='V7u1A'>

          <legend id='V7u1A'><style id='V7u1A'><dir id='V7u1A'><q id='V7u1A'></q></dir></style></legend>

            <tfoot id='V7u1A'></tfoot>
              <bdo id='V7u1A'></bdo><ul id='V7u1A'></ul>
            • <i id='V7u1A'><tr id='V7u1A'><dt id='V7u1A'><q id='V7u1A'><span id='V7u1A'><b id='V7u1A'><form id='V7u1A'><ins id='V7u1A'></ins><ul id='V7u1A'></ul><sub id='V7u1A'></sub></form><legend id='V7u1A'></legend><bdo id='V7u1A'><pre id='V7u1A'><center id='V7u1A'></center></pre></bdo></b><th id='V7u1A'></th></span></q></dt></tr></i><div id='V7u1A'><tfoot id='V7u1A'></tfoot><dl id='V7u1A'><fieldset id='V7u1A'></fieldset></dl></div>
                本文介绍了是否可以从存在 Azure 函数的同一文件夹中读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在我的 Azure C# 函数中,我需要读取一个 .txt 文件.我在 Visual Studio 中制作 .txt 文件并将其设置为始终复制".

                In my Azure C# function I need to read a .txt file. I make the .txt file in Visual studio and set it to "copy Always".

                现在我正在使用这段代码来读取文件

                Now I am using this code to read the file

                var dir = System.IO.Path.GetDirectoryName(
                    System.Reflection.Assembly.GetEntryAssembly().Location);
                
                var path = System.IO.Path.Combine(dir, "twinkle.txt");
                

                此代码不起作用.当我打开文件夹时 dir 的值.它把我带到这个目录 ""C:Users{username}AppDataLocalAzure.Functions.Cli1.0.9""

                this code doesn't work. When I open the folder which is the value of dir. It lead me to this directory ""C:Users{username}AppDataLocalAzure.Functions.Cli1.0.9""

                如何在 Azure 函数中存储一个简单的 txt 文件.或者我需要 Azure 存储.

                How I can store a simple txt file in Azure function. Or I need Azure Storage for this.

                我还能做些什么来完成这项工作.

                Anything else I can do to get this done.

                显示已复制文件的更新

                推荐答案

                这里是如何到达正确的文件夹:

                Here is how to get to the correct folder:

                public static HttpResponseMessage Run(HttpRequestMessage req, ExecutionContext context)
                {
                    var path = System.IO.Path.Combine(context.FunctionDirectory, "twinkle.txt");
                    // ...
                }
                

                这会将您带到包含 function.json 文件的文件夹.如果你需要进入 bin 文件夹,你可能需要上一级,然后附加 bin:

                This gets you to the folder with function.json file. If you need to get to bin folder, you probably need to go 1 level up, and then append bin:

                // One level up
                Path.GetFullPath(Path.Combine(context.FunctionDirectory, "..\twinkle.txt"))
                
                // Bin folder
                Path.GetFullPath(Path.Combine(context.FunctionDirectory, "..\bin\twinkle.txt"))
                

                这篇关于是否可以从存在 Azure 函数的同一文件夹中读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何从 Azure 函数返回 JSON 下一篇:单例 Azure 函数作为单独的实例运行

                相关文章

                <legend id='wbrTl'><style id='wbrTl'><dir id='wbrTl'><q id='wbrTl'></q></dir></style></legend>
                <i id='wbrTl'><tr id='wbrTl'><dt id='wbrTl'><q id='wbrTl'><span id='wbrTl'><b id='wbrTl'><form id='wbrTl'><ins id='wbrTl'></ins><ul id='wbrTl'></ul><sub id='wbrTl'></sub></form><legend id='wbrTl'></legend><bdo id='wbrTl'><pre id='wbrTl'><center id='wbrTl'></center></pre></bdo></b><th id='wbrTl'></th></span></q></dt></tr></i><div id='wbrTl'><tfoot id='wbrTl'></tfoot><dl id='wbrTl'><fieldset id='wbrTl'></fieldset></dl></div>
                    <bdo id='wbrTl'></bdo><ul id='wbrTl'></ul>

                  1. <tfoot id='wbrTl'></tfoot>

                    <small id='wbrTl'></small><noframes id='wbrTl'>