社区
C#
帖子详情
关于Server.MapPath,在线等结果
wangwei155
2006-09-08 03:42:30
我的string FilePath=Server.MapPath("../../Photo/Up/"+UserId+"/"+PhotoPath);
Response.Write(FilePath);//输出C:InetputwwwrootPhotoUp123123.jpg
PhotoPath为字符串变量
大家帮我看看,在线等结果啊
...全文
285
14
打赏
收藏
关于Server.MapPath,在线等结果
我的string FilePath=Server.MapPath("../../Photo/Up/"+UserId+"/"+PhotoPath); Response.Write(FilePath);//输出C:InetputwwwrootPhotoUp123123.jpg PhotoPath为字符串变量 大家帮我看看,在线等结果啊
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
14 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
wangwei155
2006-09-09
打赏
举报
回复
哦,这样啊,谢谢
结贴吧
chaircat
2006-09-09
打赏
举报
回复
只有不希望\转义的时候才要用到@符号...
现在只用到了/而已...需要@么...
vshake
2006-09-09
打赏
举报
回复
string FilePath=Server.MapPath(@"../../Photo/Up/"+UserId+@"/"+PhotoPath);
wangwei155
2006-09-09
打赏
举报
回复
没人吗,继续顶
wangwei155
2006-09-08
打赏
举报
回复
怎么用?
在Application里好像根本没有这个startup方法吧,查了下,vb.NET有
wthorse
2006-09-08
打赏
举报
回复
用application.startup吧
wangwei155
2006-09-08
打赏
举报
回复
string FilePath=Server.MapPath("~/Photo/Up/"+UserId+"/") +PhotoPath;
结果一样
Response.Write("<script lanuage=javascript>alert('"+FilePath+"');</script>");
结果:C:inetPutwwwrootPhoto~PhotoUp123123
string FilePath=Server.MapPath("..//..//Photo//Up//"+UserId+"//"+PhotoPath);
也不行,结果:C:inetPutwwwrootPhotoPhotoUp123123
string FilePath=Server.MapPath(@"../../Photo/Up/"+UserId+"/"+PhotoPath);
同样
wangwei155
2006-09-08
打赏
举报
回复
感激不尽,我试试
blueice008
2006-09-08
打赏
举报
回复
string FilePath=Server.MapPath(@"../../Photo/Up/"+UserId+"/"+PhotoPath);
string FilePath=Server.MapPath("..//..//Photo//Up//"+UserId+"//"+PhotoPath);
这样试试.
Ice_wang
2006-09-08
打赏
举报
回复
哦,刚才错了阿,你要的是路径是把,那你就多加“/”贝,再不行你就Http有一个类阿
v192
2006-09-08
打赏
举报
回复
我晕,我看错了。你真大意!!
string FilePath=Server.MapPath("~/Photo/Up/"+UserId+"/") +PhotoPath;
Ice_wang
2006-09-08
打赏
举报
回复
FilePath=Server.MapPath("../../Photo/Up/"+UserId+"/"+PhotoPath);
Response.Write(FilePath);
FilePath.Substring(FilePath.LastIndexOf("//"));
//输出C:InetputwwwrootPhotoUp123123.jpg
wangwei155
2006-09-08
打赏
举报
回复
楼上兄弟试过了,结果是C:inetPutwwwrootPhoto~PhotoUp123123
v192
2006-09-08
打赏
举报
回复
string FilePath=Server.MapPath("~/Photo/Up/"+UserId+"/"+PhotoPath);
C#-
Server
.
Map
Path
()说明
Server
.
Map
Path
("/") //返回应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\
Server
.
Map
Path
("~") //表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置 如:C:\Inetpub\wwwroot\Example\注:等效于
Server
.
Map
Path
("~")。
Server
.
Map
Path
("...
System.Web.HttpContext.
Server
.
Map
Path
()
总注:
Server
.
Map
Path
获得的路径都是服务器上的物理路径,也就是常说的绝对路径1、
Server
.
Map
Path
("/")注:获得应用程序根目录所在的位置,如 C:\Inetpub\wwwroot\。2、
Server
.
Map
Path
("./")注:获得所在页面的当前目录,等价于
Server
.
Map
Path
("")。3、
Server
.
Map
Path
("../")注:获得所在页面的上级目录。4...
关于
Server
.
Map
Path
()
用法: 1.
Server
.
Map
Path
("/") 应用程序根目录所在的位置 如 C:/Inetpub/wwwroot/ 2.
Server
.
Map
Path
("./") 表示所在页面的当前目录 注:等价于
Server
.
Map
Path
("") 返回
Server
.
Map
Path
("")所在页面的物理文件路径 3.
Server
.
Map
Path
("../")表示上一级目录 4.
Server
.
Map
Path
("~/")表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所
关于
Server
.
Map
Path
和HostingEnvironment.
Map
Path
最近做的项目需要在Controller里重写一个static的方法,在方法内用常用的
Server
.
Map
Path
会报一个错误:An object reference is required for the non-static field, method, or property 'Controller.
Server
'。从错误可以看出来,
Server
.
Map
Path
并不是一个static方法,所...
HttpContext.Current.
Server
.
Map
Path
(
path
) 未将对象设置到对象的实例异常。
多线程中的System.Web.HttpContext.Current.
Server
.
Map
Path
("/") 多线程中(包括在async 中),
Server
.
Map
Path
会失效。。。 获取为Null 网上找到几种解决方法,现在整理如下: 第一种: System.Web.HttpContext.Current.
Server
.
Map
Path
("/") 这个常用来表示网站的根目录,但是在多线程中,会发生未将对象引用设置到对象的实例。 所以不要分布在不同的类中,尽量在一个全局位置,然后其它类共用这..
C#
110,538
社区成员
642,577
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章