首页 > 代码库 > 获取SilverLight.Web项目中路径Uri

获取SilverLight.Web项目中路径Uri

方法一:

//获取指定要呈现的xaml内容的包活xaml文件Uri var strFullUrl = Application.Current.Host.Source.AbsoluteUri; if (strFullUrl.IndexOf("ClientBin") > 0) { var uristr = strFullUrl.Substring(0, strFullUrl.IndexOf("ClientBin")) + "Report/Default.aspx"; var uri = new Uri(uristr); }

方法二:

var uri = new Uri(App.Current.Host.Source, "../Report/Default.aspx");

方法三:

string url = System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(); var struri = url.Substring(0, url.LastIndexOf("/")) + "/Report/Default.aspx"; var uri = new Uri(struri);

方法四:

获取网页根目录

var xapUri = Application.Current.Host.Source; var uri = new Uri(xapUri, "../");