SilverLight 得到文件绝对路径


public static string GetAbsoluteUrl(string strRelativePath) { if (string.IsNullOrEmpty(strRelativePath)) return strRelativePath; string strFullUrl; if (strRelativePath.StartsWith("http:", StringComparison.OrdinalIgnoreCase) || strRelativePath.StartsWith("https:", StringComparison.OrdinalIgnoreCase) || strRelativePath.StartsWith("file:", StringComparison.OrdinalIgnoreCase) ) { //already absolute strFullUrl = strRelativePath; } else { //relative, need to convert to absolute strFullUrl = System.Windows.Application.Current.Host.Source.AbsoluteUri; if (strFullUrl.IndexOf("ClientBin") > 0) strFullUrl = strFullUrl.Substring(0, strFullUrl.IndexOf("ClientBin")) + strRelativePath; } return strFullUrl; }

  

原文地址:https://www.cnblogs.com/zhangxin1989/p/2797208.html