2009-11-16 174 views
0

大家好我不是.net开发人员我来自PHP,python背景,我不知道该怎么做。.net问题“路径中存在非法字符”。

尝试加载我们的某个网站时出现以下错误。可以请别人帮忙

[ArgumentException: Illegal characters in path.] System.IO.Path.CheckInvalidPathChars(String path) +7491109 System.IO.Path.GetFileName(String path) +19 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +16 System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) +77 System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +54 System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) +74 System.Threading.CompressedStack.runTryCode(Object userData) +70 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) +0 System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state) +108 System.Xml.XmlTextReaderImpl.OpenUrl() +186 System.Xml.XmlTextReaderImpl.Read() +208 System.Xml.XPath.XPathDocument.LoadFromReader(XmlReader reader, XmlSpace space) +217 System.Xml.XPath.XPathDocument..ctor(String uri, XmlSpace space) +116 System.Xml.XPath.XPathDocument..ctor(String uri) +6 OpenBay.Utils.XPathUtils.GetNodes(String xpathQuery, String xmlFile) +30 OpenBay.Wms.Controllers.SiteController.SetErrorPages(Site site) +21 OpenBay.Wms.Controllers.SiteController.GetSite(Uri uri, DirectoryInfo dir, String applicationName) +104 OpenBay.Wms.HttpModule.UrlProcessHttpModule.GetSiteParameters(HttpApplication app, RequestInfo info) +172 OpenBay.Wms.HttpModule.UrlProcessHttpModule.ProcessRequest(Object o, EventArgs args) +338 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

thanks guys

+0

如果您提供了路径名,那么我们可以查找不允许的字符会更有帮助。 – ZippyV 2009-11-16 11:22:36

回答

2

您的代码将调用System.IO.Path.CheckInvalidPathChars,这反过来将检查以下内容:

  1. 双引号(“)

  2. 左尖括号(< )

  3. 直角支架(>)

  4. veritical条(|)

和用于控制字符小于32十进制(空间)。

所以请确保您的路径不包含它们。

编辑: comment from Guy Lowe

我的问题是我的转义\在C:\使它C:\固定它

+0

对不起,我不确定System.IO.Path.CheckInvalidPathChars在哪里。我在哪里可以找到这个? – Ben 2009-11-16 11:31:03

+0

你会在'System.IO.Path'命名空间中找到它,重要的是要确保你的路径不包含上述字符。 – Graviton 2009-11-16 11:33:28

+0

您需要在使用Path类之前导入'System.IO'命名空间(无需引用任何在mscorlib中声明的dll) – Yogesh 2009-11-16 11:36:03

0

尼斯堆栈跟踪,但无效的路径会比较有帮助。

在我的oponion中,提供给OpenBay.Utils.XPathUtils.GetNodes(string,string)的路径有一些无效参数。使用System.IO.Path.CheckInvalidPathChars()来检查哪些字符无效并可能包含在提供给上述方法的参数中。

+0

对不起,路径只是我们没有改变网站上的任何东西很长一段时间的域根,所以这是突出的。使用System.IO.Path.CheckInvalidPathChars()位于何处? – Ben 2009-11-16 11:32:11

相关问题