[英]I got error when i try to acces an image folder?
Iam tried to access an image folder,but when i try to run i got an error Iam尝试访问图像文件夹,但是当我尝试运行时出现错误
"C:/Users/glos/Desktop/My Proj /My Proj/projects//images1' is a physical path, but a virtual path was expected."
“ C:/ Users / glos / Desktop / My Proj / My Proj / projects // images1'是物理路径,但是应该使用虚拟路径。”
My code 我的密码
public object post([FromBody]string value)
{
var path = HttpContext.Current.Server.MapPath("C:\\Users\\glos\\Desktop\\My Proj\\ projects\\images1");
var images = Directory.GetFiles(path, "*.png");
foreach (var image in images)
{
System.Console.WriteLine(image);
}
return (images);
}
So how can i create a virtual path ? 那么如何创建虚拟路径 ?
When you know that the file exists in C:\\\\Users\\\\glos\\\\Desktop
why do you need Server.MapPath
? 当您知道该文件存在于
C:\\\\Users\\\\glos\\\\Desktop
为什么需要Server.MapPath
? - it is needed only when you have a relative path like ~/folder1/folder2
. -仅当您具有
~/folder1/folder2
类的相对路径时才需要它。
You can also use Directory.GetFiles 您也可以使用Directory.GetFiles
Directory.GetFiles(@"C:\\Users\\glos\\Desktop\\My Proj...");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.