如何获得在蔚蓝的网站的本地文件系统路径 [英] How to get local file system path in azure websites

查看:135
本文介绍了如何获得在蔚蓝的网站的本地文件系统路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我主持的磁盘上的文件和我的网站,我想读的。不肯定我该如何访问文件时,我用它System.Environment.CurrentDirectory点到D盘的位置。可有人告诉我沿着我怎样才能到储存在哪里我的网站托管的根我的文件。

I have a file hosted on the disk along with my website that I want to read .Not sure how do I access the file when I use System.Environment.CurrentDirectory it point to a D drive location .Can someone please tell me how can I get to my file stored at the root of where my site is hosted.

感谢

推荐答案

有一个叫家在您的网站的环境中的环境变量,将让你的一部分的方式存在。

There is an environment variable called HOME in your website's environment that will get you part way there.

您可以使用剃刀语法或code(C#)访问它。例如,假设你有一个名为Data.txt文件是在您的网站默认的文档和文件的其余部分的根。你可以得到是这样的完整路径。

You can access it using razor syntax or in code (C#). For example, suppose you have a file called data.txt that is at the root of your site with the default document and the rest of your files. You could get it's full path like this.

@{ var dataFileName = Environment.GetEnvironmentVariable("HOME").ToString() + "\\site\\wwwroot\\data.txt"; }

您可以使用站点控制管理/捻你自己发现这一点。例如,如果你的网站是contoso.azurewebsites.net,然后简单地浏览到Contoso。 SCM .azurewebsites.net。在这里你可以了解所有有关文件系统和环境变量提供给您的网站。

You can find this out on your own using the Site Control Management/"Kudu". For example, if your website is contoso.azurewebsites.net, then simply navigate to contoso.scm.azurewebsites.net. In here you can learn all about the file system and environment variables available to your website.

这篇关于如何获得在蔚蓝的网站的本地文件系统路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆