Label1.Text=Server.MapPath(""); //返回值为d:\inetpub\wwwroot\yxbwebapplication
File.Exists(Server.MapPath("image\\")+"my.bmp");//其路径为d:\inetpub\wwwroot\yxbwebapplication\image\my.bmp
Label1.Text=AppDomain.CurrentDomain.BaseDirectory;//返回值为d:/inetpub/wwwroot/yxbwebapplication/
非常有用的写法(在网页中有个存放图片的image目录下图片的路径)
Image1.ImageUrl="image\\TOP.bmp";
文章介绍了如何在ASP.NET中使用Server.MapPath获取Web应用程序的根目录,以及如何结合File.Exists检查文件存在性,还展示了如何设置Image控件的ImageUrl以指向特定的图片路径。
757

被折叠的 条评论
为什么被折叠?



