c# - 如何使用 Server.MapPath 将文件上传到映射在我的计算机上的服务器
问题描述
到目前为止,我知道如何使用下面的代码将文件上传到我的解决方案中的文件夹。
string root = HttpContext.Current.Server.MapPath("~/upload");
如何将文件保存到不在解决方案中的其他位置,即保存到映射到我的电脑的服务器位置。
string root = HttpContext.Current.Server.MapPath("/Z:/UploadFolder"); I have tried this but its not saving to the server so where I am going wrong?
解决方案
MapPath
当你有一个相对路径并且想要使用你的项目的路径时,你应该使用它。对于您不需要的另一条路径MapPath
。像这样使用它:
string root ="Z:\\UploadFolder";
推荐阅读
- vue.js - 如果页面是从某个页面重定向的,如何在 vuejs 中添加显示组件?
- python - 为什么 Python 3 中的子进程不会执行 bash 下标并会挂在上面?我正在尝试在我自己的 Apple M1 库路径解析器中使用它
- c# - 如何删除场景中的这个红框?
- ios - 包含 2 个视图的内容优先级
- excel - 动态范围内带前缀的目标值
- javascript - 如何在 node.js 中正确导入 strophe.js 插件
- javascript - 未捕获的类型错误:无法读取 null 的属性“发送”
- c# - 如何使用 Nunit 运行所有测试 2 次
- inspec - 如何覆盖 DevSec Inspec 基线控制
- python - 使用 python 将 cx_oracle 数据集/数组转换为 json