未能找到路径“C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\~\ControlConfig.

panzhuanxin4 2011-10-17 09:41:31
未能找到路径“C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\~\ControlConfig.
提示这部分代码错误
    public DataSet  ReadXml()
{
DataSet ds = new DataSet();
ds.ReadXml("ControlConfig.xml");
return ds;
}

ds.ReadXml("ControlConfig.xml");
改成 ds.ReadXml("~/ControlConfig.xml");
跟 ds.ReadXml("./ControlConfig.xml");
都没用啊
...全文
1450 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
弦弦 2011-10-17
  • 打赏
  • 举报
回复
在.cs文件使用Session,Request,Response,Server的时候,HttpContext.Current 就可以用了
panzhuanxin4 2011-10-17
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 beyond_me21 的回复:]

所有有关ControlConfig.xml都要换成HttpContext.Current.Server.MapPath("~/ControlConfig.xml")
[/Quote]

嗯弄出来了
panzhuanxin4 2011-10-17
  • 打赏
  • 举报
回复
[Quote=引用 19 楼 nevermore_0923 的回复:]

引用 17 楼 beyond_me21 的回复:

using System.Web.HttpContext.Current.Server.MapPath;这一行去了,引用命名空间只要using System.Web就可以了

然后string path = System.Web.HttpContext.Current.Server.MapPath("./") + "ControlCon……
[/Quote]
上面那位的方法
弄出来了
弦弦 2011-10-17
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 beyond_me21 的回复:]

using System.Web.HttpContext.Current.Server.MapPath;这一行去了,引用命名空间只要using System.Web就可以了

然后string path = System.Web.HttpContext.Current.Server.MapPath("./") + "ControlConfig.xml";这里

string path ……
[/Quote]

你在cs文件中调用Server看看?
beyond_me21 2011-10-17
  • 打赏
  • 举报
回复
所有有关ControlConfig.xml都要换成HttpContext.Current.Server.MapPath("~/ControlConfig.xml")
beyond_me21 2011-10-17
  • 打赏
  • 举报
回复
using System.Web.HttpContext.Current.Server.MapPath;这一行去了,引用命名空间只要using System.Web就可以了

然后string path = System.Web.HttpContext.Current.Server.MapPath("./") + "ControlConfig.xml";这里

string path = HttpContext.Current.Server.MapPath("~/ControlConfig.xml");
弦弦 2011-10-17
  • 打赏
  • 举报
回复
我晕死

public void WriteXml(string controlMsg, string controlType, string controlID,string XmlPath)//把地址定义成一个参数,然后在aspx.cs文件中赋值。
{
panzhuanxin4 2011-10-17
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 nevermore_0923 的回复:]

把你页面代码都贴出来。
[/Quote]
东西本来是 .NET 2.0的
我转换成 3.5的了
panzhuanxin4 2011-10-17
  • 打赏
  • 举报
回复

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.HttpContext.Current.Server.MapPath;

using System.Xml;


/// <summary>
/// Summary description for ControlXml
/// </summary>
public class ControlXml
{
public ControlXml()
{
//
// TODO: Add constructor logic here
//
}
public void WriteXml(string controlMsg, string controlType, string controlID)
{
//初始化XML文档操作类
XmlDocument myXml = new XmlDocument();

//加载指定的XML文件
myXml.Load("ControlConfig.xml");

//添加元素-姓名
XmlElement ele0 = myXml.CreateElement("controlType");
XmlText Text0 = myXml.CreateTextNode(controlType);
XmlElement ele1 = myXml.CreateElement("controlMsg");
XmlText Text1 = myXml.CreateTextNode(controlMsg);
XmlElement ele2 = myXml.CreateElement("controlID");
XmlText Text2 = myXml.CreateTextNode(controlID);


//添加元素的节点---studentRecord
XmlNode newElem = myXml.CreateNode("element","Controls", "");

//在节点中添加元素
newElem.AppendChild(ele0);
newElem.LastChild.AppendChild(Text0);
newElem.AppendChild(ele1);
newElem.LastChild.AppendChild(Text1);
newElem.AppendChild(ele2);
newElem.LastChild.AppendChild(Text2);


//将节点添加到文档中
XmlElement root = myXml.DocumentElement;
root.AppendChild(newElem);

//保存所有的修改
myXml.Save("ControlConfig.xml");

}
public DataSet ReadXml()
{
DataSet ds = new DataSet();
//ds.ReadXml(Server.Mappath("ControlConfig.xml"));
string path = System.Web.HttpContext.Current.Server.MapPath("./") + "ControlConfig.xml";
ds.ReadXml(path);
return ds;
}
public void DelXml()
{
XmlDocument myXml = new XmlDocument();
//加载指定的XML文件
myXml.Load("ControlConfig.xml");
//myXml.RemoveChild();
}


}

弦弦 2011-10-17
  • 打赏
  • 举报
回复
把你页面代码都贴出来。
panzhuanxin4 2011-10-17
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 nevermore_0923 的回复:]

HttpServerUtility 这什么东西?

你页面最上面难道没有using System.Web;这个么?
[/Quote]

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web;
using System.Web.HttpContext.Current.Server.MapPath;

using System.Xml;

引用 有的啊
panzhuanxin4 2011-10-17
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 nevermore_0923 的回复:]

HttpServerUtility 这什么东西?

你页面最上面难道没有using System.Web;这个么?
[/Quote]
复制错了 ...是
CS0426: 类型“System.Web.HttpContext”中不存在类型名称“Current”
弦弦 2011-10-17
  • 打赏
  • 举报
回复
HttpServerUtility 这什么东西?

你页面最上面难道没有using System.Web;这个么?
panzhuanxin4 2011-10-17
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 nevermore_0923 的回复:]

System.Web.HttpContext.Current.Server.MapPath
[/Quote]
还是这个问题
using 命名空间指令只能应用于命名空间;“System.Web.HttpServerUtility”是一个类型,而不是命名空间
弦弦 2011-10-17
  • 打赏
  • 举报
回复
string path=System.Web.HttpContext.Current.Server.MapPath("./")+"ControlConfig.xml";
ds.ReadXml(path);
弦弦 2011-10-17
  • 打赏
  • 举报
回复
System.Web.HttpContext.Current.Server.MapPath
panzhuanxin4 2011-10-17
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 tangchengn 的回复:]

ds.ReadXml(Server.MapPath("ControlConfig.xml"));
[/Quote]
当前上下文中不存在名称“Server”出现的是这个
引用空间不知道要添加的是什么
tangchengn 2011-10-17
  • 打赏
  • 举报
回复
ds.ReadXml(Server.MapPath("ControlConfig.xml"));
panzhuanxin4 2011-10-17
  • 打赏
  • 举报
回复
[Quote=引用楼主 panzhuanxin4 的回复:]
未能找到路径“C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\~\ControlConfig.
提示这部分代码错误
C# code
public DataSet ReadXml()
{
DataSet ds = new DataSet();
ds.ReadXml("Contro……
[/Quote]
ds.ReadXml(Server.Mappath("~/ControlConfig.xml"));
这个我用过 他说找不到 Server 引用空间 不知道引用什么
using System.Web.HttpServerUtility
用这个 他说using 命名空间指令只能应用于命名空间;“System.Web.HttpServerUtility”是一个类型,而不是命名空间
bdmh 2011-10-17
  • 打赏
  • 举报
回复
你那个是相对路径,是在客户端还是在服务器
加载更多回复(2)
mvc安装框架和指南,mvc1.0 英文版安装完就可以出现MVC模板。 目前遇到问题的基本集中在Microsoft Visual Studio 2008中文版,因为中文版所有的安装文件默认放在2052(中文编码)下面,而ASP.NET MVC是英文的,所有都放在1033下面,所以导致ASP.NET MVC模板不能载入。 于是就找到了下面的解决方案: 修改下面文件夹的名称(X为您对应的安装盘符): X:/Program FilesMicrosoft / Visual Studio 9.0/Common7/IDE/ItemTemplates/CSharp/Web/MVC/1033 X:/Program FilesMicrosoft/ Visual Studio 9.0/Common7/IDEItemTemplatesCache/CSharp/Web/MVC/1033 为 X:/Program FilesMicrosoft / Visual Studio 9.0/Common7/IDE/ItemTemplates/CSharp/Web/MVC/2052 X:/Program FilesMicrosoft/ Visual Studio 9.0/Common7/IDEItemTemplatesCache/CSharp/Web/MVC/2052 然后将 X:/Program FilesMicrosoft/ Visual Studio 9.0/Common7/IDE/ProjectTemplates/CSharp/Web/1033 X:/Program FilesMicrosoft/ Visual Studio 9.0/Common7/IDE/ProjectTemplatesCache/CSharp/Web/1033 文件夹里的内容剪切到 X:/Program FilesMicrosoft/ Visual Studio 9.0/Common7/IDE/ProjectTemplates/CSharp/Web/2052 X:/Program FilesMicrosoft/ Visual Studio 9.0/Common7/IDE/ProjectTemplatesCache/CSharp/Web/2052 文件夹中,到这里文件路径问题就解决了。 在命令行运行: X:Program Files/Microsoft Visual Studio 9.0/Common7/IDE/devenv.exe /setup 因为重建索引需要一点时间,等待大概几秒钟再打开你的VS2008就可以看到MVC项目模板了。 至此就完成了ASP.NET MVC框架在Microsoft Visual Studio 2008中文版的安装。 vs 2008 过期问题 安装完90天试用版后,在“添加或删除应用程序”,删除vs 2008,点击“更改/删除”(等一会儿在左边会出现一个输入序号的地方,输入“PYHYP-WXB3B-B2CCM-V9DX9-VDY8T”序号,输入完后点【升级】就行了,不是真卸载)把正式版的序列号输入进去就行了

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧