【问题标题】:How can get real server folder location by configurationmanager.appsettings["__"]?如何通过 configurationmanager.appsettings["__"] 获取真实的服务器文件夹位置?
【发布时间】:2023-04-04 03:59:01
【问题描述】:

在真实的项目和真实的在线服务器中,我如何获取或如何分配?

网络配置

<appSettings>
   <add key="FilePath" value="~/Document/" />
</appSettings>

控制器

public FileStreamResult GetFile(int Id)
{
    var model = _unitOfWork.LstDocumentRepository.Get(s => s.Id == Id).First();
    string Cat_Name = _manager.Get_Cat_Name(Id);
    string fileName = _manager.FileNameSearch(Id);
    string filePath = ConfigurationManager.AppSettings["FilePath"] + Cat_Name + "/" + fileName;
    FileStream fs = new FileStream(Server.MapPath(filePath), FileMode.Open, FileAccess.Read);             
}

我想在 web.config 中从真实服务器检索文件位置

<appSettings>
 <add key="FilePath" value="??"/> 

【问题讨论】:

    标签: c# asp.net asp.net-mvc


    【解决方案1】:

    如果您在根文件夹中的文件路径位置与我们相同 (~/) 并且如果您在文件夹内的路径可能会尝试使用 (../)。

    Also Refer following link for you question

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-08
      • 2013-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      相关资源
      最近更新 更多