asp.net - Can't find file -


I am working on a custom menu system in asp.net, which allows horizontal menus to fly on the basis of menu items. Populates is selected from the main menu of the website.

This second menu is populated from the custom XML file in the website's root directory. (See for details).

At that time I wrote that post, he worked, but my development environment has changed and now I am getting the error saying that the XML file can not be found.

This is my code:

  import system. Acquisition of XML Partial Class Site System. Web.UI.MasterPage Protected sub-menu 1_MenuItemClick (as object byVal sender, ByVal e as System.Web.UI.WebControls.MenuEventArgs) handle menu 1. Menu itemClick Episode Select e.Item.Value.ToString Case "Team" Dim Doc named as New Name XmlDocument doc.Load ("~ / Submenus.xml") named as Dim NameNodes XmlNodeList = doc ("/ TeamMenu / Item / URL") named URLNodes ("/ Team Manage / Item / URL "). If NameNodes.Count = URLNodes.Count for I then to Integer = 0 NameNodes. Calculation - New MenuItem m.Text = NameNodes.Item (i) as 1 dim M. FirstChi Ld.Intextext m.NavigateUrl = URLNodes.Item (i). FirstChild.InnerText Menu2.Items.Add (m) Next End if the case "investment" dim dock new XmlDocument doc.Load ("~ / Submenus.xml") as dim nameNodes as XmlNodeList = doc.SelectNodes ("/ InvestmentsMenu / item / name ") Dim URLNodes as XmlNodeList = doc.SelectNodes (" / InvestmentsMenu / item / url ") if nameNodes.Count = URLNodes.Count then i as integer = 0 NameNodes.Count-1 Dimm as new MenuItem m.Text = NameNodes.Item (i). FirstChild.InnerText m.NavigateUrl = URLNodes.Item (i). FirstChild.InnerText Menu2.Items.Add (m) Next End if the case "Social Responsibility" is a new XML Dot Dock as Dim Doc. L oom ("~ / Submenus.xml") XMLNODOD = Doctor as XMLNodeLIS. Select Node ("/Investmenu / Item / Name") as XML URLNodes as XmlNodeList = doc.SelectNodes ("/ InvestmentsMenu / item / url") if NameNodes.Count = URL Nodes. Again, as integer for I = 0, name.Count- 1 Dimm as new MenuItem m.Text = NameNodes.Item (i). FirstChild.InnerText m.NavigateUrl = URLNodes.Item (i). FirstChild.InnerText Menu2.Items.Add (m) Next End If End Stitched and Substitutes and Class  

and here I am getting the error: Not a part of Could not find the path 'c: \ windows \ system32 \ inetsrc \ ~ \ Submenus.xml'.

Menu 2 is just a completely empty & lt; Asp: menu & gt; Control directly under the main menu on the page.

Can anyone tell me what I am doing wrong?

Thanks in advance.

XmlDocument.Load is expecting a file path where you are providing a virtual path. Try changing it:

  doc.Load (Page.MapPath ("~ / Submenus.xml"))  

Comments