给定路径';c#Asp.Net MVC不支持s格式

给定路径';c#Asp.Net MVC不支持s格式,c#,C#,字符串路径=path.Combine(“~/Content/Images/”+pic.FileName); pic.SaveAs(Server.MapPath(path)) 您可以尝试以下方法: string path = Server.MapPath("~/Content/Images/"); pic.SaveAs(Path.Combine(path, pic.FileName)); 这里有问题吗?标题是不是你得到的实际错误?哪一行抛出错误?哪个操作抛出错误?pic.FileName的运行时

字符串路径=path.Combine(“~/Content/Images/”+pic.FileName); pic.SaveAs(Server.MapPath(path))

您可以尝试以下方法:

string path = Server.MapPath("~/Content/Images/");
pic.SaveAs(Path.Combine(path, pic.FileName));

这里有问题吗?标题是不是你得到的实际错误?哪一行抛出错误?哪个操作抛出错误?
pic.FileName的运行时值是多少?路径的
Server.MapPath(path)
的输出?请详细说明您试图询问的内容。string path=path.Combine(“~/Content/Images/”+pic.FileName);此行引发无效路径格式的异常。。。。运行时文件名为pic。我正在尝试将图像上载到解决方案中的“~/Content/Images”文件夹。非常感谢…@boredomload。异常已消失,但文件未上载到文件夹…@Adnan这太糟糕了,但我认为这是一个问题本身,与此问题无关。希望你能解决问题!:)