【问题标题】:Save Images to folder located in wwwroot将图像保存到位于 wwwroot 的文件夹中
【发布时间】:2020-06-25 16:16:26
【问题描述】:

我在 wwwroot 文件夹中有一个名为 Images 的文件夹。我想将图像保存到该文件夹​​。现在图像被保存在 wwwroot 文件夹(在 Images 之外),并且保存的图像的名称以 Images 开头。这是我正在使用的代码:

  string filepath = Path.Combine(_caminho.WebRootPath, "Images" + name);

"name" 是具有图像名称的字符串。为什么会这样?

【问题讨论】:

  • 看起来“图片”被添加到名称前。在没有看到更多代码的情况下,我不得不假设您应该这样做:string filepath = Path.Combine(_caminho.WebRootPath, "Images", name);

标签: c# visual-studio asp.net-core


【解决方案1】:

您似乎将字符串"Images" 连接到name。我建议你这样做

(..."Images", name);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-08
    • 2020-07-15
    • 1970-01-01
    • 1970-01-01
    • 2021-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多