服务器上的.net核心访问共享文件夹

时间:2018-06-29 11:11:36

标签: asp.net-core-2.0 windows-7-x64

我正在构建一个小型应用程序,并希望从项目外部的目录访问文件(IE图像),但是该应用程序将在服务器上运行。

如何访问所需的目录?

1 个答案:

答案 0 :(得分:0)

我在Configure中的Startup.cs中使用了此功能

    app.UseFileServer(new FileServerOptions()
    {
        FileProvider = new PhysicalFileProvider(env.ContentRootPath + "/Albums"),
        RequestPath = new PathString("/Albums"),
        EnableDirectoryBrowsing = true
    });

从应该使用它的模型中:

Initialize(_environment.WebRootPath + "/Albums");
相关问题