Server.MapPath路径问题

wangqiao208 2013-01-25 11:11:50
string _filedir = Server.MapPath("192.168.0.222/E:/upload");
报错
不支持给定路径的格式。
E:\upload 在192.168.0.222是存在的
...全文
96 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
threenewbee 2013-01-25
  • 打赏
  • 举报
回复
Server.MapPath的作用是把和网站虚拟路径相关的相对路径转换为物理路径(盘符开始的路径)。 比如相对于网站来说\upload,而网站位于C:\wwwroot\website1那么传入\upload它返回C:\wwwroot\website1\upload1。
鸭梨山大帝 2013-01-25
  • 打赏
  • 举报
回复
共享 192.168.0.222 下 E:/upload --> Upload,当然设置好授权 然后程式直接访问 string _filedir = "\\192.168.0.222\Upload" 不需要使用Server.MapPath
宝_爸 2013-01-25
  • 打赏
  • 举报
回复
MapPath: eturns the physical file path that corresponds to the specified virtual path on the Web server. 你的路径是virtual path on the Web server.吗?
threenewbee 2013-01-25
  • 打赏
  • 举报
回复
那不需要Server.MapPath 直接用string _filedir = @"\\192.168.0.222\E\upload" 就可以了。 记得先将E:\设置为共享目录,在防火墙中允许文件共享,再在程序中先用WNetAddConnection2建立连接。

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧