using System; using System.Collections.Generic; using System.IO; namespace uc { public static class StringExtention { static public int[] ConvertToPageRange(this string str) { HashSet col = new HashSet(); string[] ranges = str.Split(','); foreach(var s in ranges) { int page; if(int.TryParse(s, out page)) { col.Add(page); } else { string[] pages = s.Split('-'); int start, end; if(pages.Length == 2 && int.TryParse(pages[0], out start) && int.TryParse(pages[1], out end)) { for(int i = start; i<= end; i++) { col.Add(i); } } } } int[] result = new int[col.Count]; col.CopyTo(result); return result; } static public string GetRelativePath(this string targetPath, string refPath) { refPath = Path.GetFullPath(refPath + "/foo").Replace(@"\", @"/"); Uri baseUri = new Uri(refPath); //Debug.Log("Base Path: " + baseUri); targetPath = Path.GetFullPath(targetPath).Replace(@"\", @"/"); Uri targetUri = new Uri(targetPath ); //Debug.Log("Target Path: " + targetUri); Uri relUri = baseUri.MakeRelativeUri(targetUri); return relUri.ToString().Replace(@"/", @"\"); } } }