SaveAs 方法配置为需要根路径,并且路径“~\\images\\594083964.jpg”没有扎根
SaveAs 方法配置为需要根路径,而路径“~\images\594083964.jpg”不是根路径。 描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:
System.Web.HttpException:SaveAs 方法配置为需要根路径,而路径“~\images\594083964.jpg”不是根路径。
源错误:
Line 27: {
Line 28:
Line 29: fu1.SaveAs(@"~\\images\\" + i + fu1.FileName.Substring(fu1.FileName.Length - 4, 4));
Line 30: path = "~\\images\\"+i + fu1.FileName.Substring(fu1.FileName.Length-4,4);
Line 31: }
源文件:e:\PEOPLE\Ravi\new data\WebSite1\signup.aspx.cs 行:29
The SaveAs method is configured to require a rooted path, and the path '~\images\594083964.jpg' is not rooted.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:
System.Web.HttpException: The SaveAs method is configured to require a rooted path, and the path '~\images\594083964.jpg' is not rooted.
Source Error:
Line 27: {
Line 28:
Line 29: fu1.SaveAs(@"~\\images\\" + i + fu1.FileName.Substring(fu1.FileName.Length - 4, 4));
Line 30: path = "~\\images\\"+i + fu1.FileName.Substring(fu1.FileName.Length-4,4);
Line 31: }
Source File: e:\PEOPLE\Ravi\new data\WebSite1\signup.aspx.cs Line: 29
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您要保存到的路径是相对 URL。您需要保存到本地文件路径(或完整网络路径)。
尝试:
(Path.GetExtension(string) 也将处理不是 3 个字符的文件扩展名)
The path you are saving to is a relative URL. You need to save to a local file path (or full network path).
Try:
(Path.GetExtension(string) will handle file extensions that aren't 3 characters too)