Silverlight獲取Web路徑

暖楓無敵發表於2012-11-14
 string[] s = { "ClientBin" };
 string url = App.Current.Host.Source.OriginalString.ToString().Split(s, StringSplitOptions.RemoveEmptyEntries)[0] + tr.IMG.ToString().Trim(new char[]{'.','/'});
 ImageBrush br = new ImageBrush();
 br.ImageSource = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute));
 but.setIcon(br);

最主要的是  App.Current.Host.Source.OriginalString 獲取路徑為 http://localhost:8080/ClientBin/XXX.xap

相關文章