[英]Server.MapPath problems
My problem is that I just can't seem to get the actual file of my mapPath in my foreeach loop.我的问题是我似乎无法在 foreeach 循环中获得 mapPath 的实际文件。
foreach (DataRow item in objKat.getProd().Rows)
{
ddlImage.Items.Add(new ListItem(Server.MapPath("../img/produkter/"), item["fldId"].ToString()));
}
The actual problem is that I don't know what to write after produkter/". Hope any of you can help me. Thank you in advance! :)实际问题是我不知道在 produkter/" 之后写什么。希望你们中的任何人都可以帮助我。提前谢谢你!:)
When you using the MapPath
your path may look look this当您使用
MapPath
您的路径可能看起来像这样
Server.MapPath("~/img/produkter/")
Read more about ASP.NET Web Project Paths阅读有关ASP.NET Web 项目路径的更多信息
IS Produkter
is a Subfolder
in img
folder. IS
Produkter
是img
文件Subfolder
中的Subfolder
文件夹。 If it's then your image name is in item["fldId"].ToString()
then use that..otherwise your Relative
path of image should be come after Produkter
如果是这样,那么您的图像名称在
item["fldId"].ToString()
然后使用它..否则您的图像的Relative
路径应该在Produkter
之后
You need to escape the strings.您需要转义字符串。 If you want to go to /somefolder/fileyoudesire.ext, it needs to be //somefolder//fileyoudesire.ext
如果你想去/somefolder/fileyoudesire.ext,它需要是//somefolder//fileyoudesire.ext
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.