Gia*_*971 4 c# asp.net streamreader
从ASP.NET中的App_Code文件夹中的类,我如何访问网站根目录的路径?我试过了:
StreamReader sr = new StreamReader("../Questions.aspx");
Run Code Online (Sandbox Code Playgroud)
但它给了我程序文件中的路径......
那我该怎么做呢?至少我以为我可以从App_Code文件夹导航到目录中的上层文件夹
编辑:我不是开发一个Web应用程序,而是一个网站
尝试使用
string filePath = System.Web.HttpContext.Current.Request.PhysicalApplicationPath;
StreamReader sr = new StreamReader(filePath + @"\Questions.aspx");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4548 次 |
| 最近记录: |