[转][C#]文件流读取

{
    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

转载于:https://www.cnblogs.com/z5337/p/10219906.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值