C# 路径不是有效的虚拟路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/942514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 03:53:11  来源:igfitidea点击:

Path is not a valid virtual path

c#asp.net

提问by GurdeepS

The below method takes a path pointing to an xml file:

以下方法采用指向 xml 文件的路径:

tree.LoadContentFile(path);

I pass a complete path from my local file system (or use Server.MapPath()), but everytime I keep getting this error:

我从本地文件系统(或使用Server.MapPath())传递完整路径,但每次我不断收到此错误:

[Path] is not a valid virtual path.

[Path] 不是有效的虚拟路径。

EDIT: I am using Telerik RadTreeView.

编辑:我正在使用Telerik RadTreeView.

A sample path is: "C:\inetpub\wwwroot\sitename\OutlookNavigation\tree.xml"

示例路径是: "C:\inetpub\wwwroot\sitename\OutlookNavigation\tree.xml"

What am I doing wrong?

我究竟做错了什么?

采纳答案by harpo

.NET is expecting a path like

.NET 期待像这样的路径

~/folder/file.txt

or /folder/file.txt

或者 /folder/file.txt

which it will translate into a physical path.

它将转化为物理路径。