{ internal static class FileUtils { public static string GetRelativePath(string absPath, string baseDirectoryPath) { char[] array = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }; baseDirectoryPath = Path.GetFullPath(baseDirectoryPath); absPath = Path.GetFullPath(absPath); baseDirectoryPath = baseDirectoryPath.TrimEnd(array); string[] array2 = baseDirectoryPath.Split(array); string[] array3 = absPath.Split(array); int num = 0; while (num < Math.Min(array2.Length, array3.Length) && string.Compare(array3[num], array2[num], true) == 0) { num++; } if (num == 0) { return absPath; } string str = ""; for (int i = num; i < array2.Length; i++) { str = str + ".." + Path.DirectorySeparatorChar.ToString(); } return str + string.Join(Path.DirectorySeparatorChar.ToString(), array3, num, array3.Length - num); } public static void CopyStream(Stream input, Stream output) { byte[] array = new byte[32768]; int count; while ((count = input.Read(array, 0, array.Length)) > 0) { output.Write(array, 0, count); } } } }
来自:https://github.com/FastReports/FastReport