本文介绍了SaveAs方法被配置为需要扎根路径,该路径'〜\\\\ \\\\图像594083964.jpg“的根源并非是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的SaveAs方法被配置为需要一个根路径,和该路径'〜\\图像\\ 594083964.jpg'没有根。
说明:执行当前Web请求的执行过程中发生未处理的异常。请检查堆栈跟踪有关该错误的详细信息以及它起源于code。

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.

异常详细信息:

System.Web.HttpException:该SaveAs方法被配置为需要一个根路径,和该路径'〜\\图像\\ 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:\\其他人\\拉维\\新数据\\的WebSite1 \\ signup.aspx.cs行:29

Source File: e:\PEOPLE\Ravi\new data\WebSite1\signup.aspx.cs Line: 29

推荐答案

您要保存到该路径是相对URL。您需要保存到本地文件路径(或完整网络路径)。

The path you are saving to is a relative URL. You need to save to a local file path (or full network path).

尝试:

string relativePath = @"~\images\"+ i + Path.GetExtension(fu1.FileName);
fu1.SaveAs(Server.MapPath(relativePath));

(Path.GetExtension(字符串)将处理不属于3个字符过的文件扩展名)

(Path.GetExtension(string) will handle file extensions that aren't 3 characters too)

这篇关于SaveAs方法被配置为需要扎根路径,该路径'〜\\\\ \\\\图像594083964.jpg“的根源并非是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 14:58