{
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 = ;
while (num < Math.Min(array2.Length, array3.Length) && string.Compare(array3[num], array2[num], true) == )
{
num++;
}
if (num == )
{
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[];
int count;
while ((count = input.Read(array, , array.Length)) > )
{
output.Write(array, , count);
}
}
}
}

来自:https://github.com/FastReports/FastReport

[转][C#]文件流读取的更多相关文章

  1. Java实现http大文件流读取并批量插入数据库

    1.概述 请求远程大文本,使用流的方式进行返回.需要设置http链接的超时时间 循环插入到List中,使用mybatis-plus批量插入到mysql中 2.需求 两台服务器 大文件放到其中一台服务器 ...

  2. Delphi 用文件流读取文本文件字符串的方法

    procedure TForm23.Button4Click(Sender: TObject); var pstr:Pchar; mestr,Str1:string; FS:TFilestream; ...

  3. c的文件流读取

    strtok(数组,分隔符); atof(数组)返回值为转换后的数字; fgets(数组指针,长度,文件句柄); 整整花了两天啊

  4. FileStream文件流的读取和写入(为以后聊天工具的设计基础)

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...

  5. C# Path类 FileStream(文件流) 与 File(文件) 读取的区别

    1.采用文件流读取数据是一点一点从文件中读取数据对内存的压力相对较小;而采用文件读取数据是一下全部读取过来对内存造成的压力相对较大 2.File读取: string str = @"E:\Q ...

  6. C++基于文件流和armadillo读取mnist

    发现网上大把都是用python读取mnist的,用C++大都是用opencv读取的,但我不怎么用opencv,因此自己摸索了个使用文件流读取mnist的方法,armadillo仅作为储存矩阵的一种方式 ...

  7. excel to datatable (c#用NPOI将excel文件内容读取到datatable数据表中)

    将excel文件内容读取到datatable数据表中,支持97-2003和2007两种版本的excel 1.第一种是根据excel文件路径读取excel并返回datatable /// <sum ...

  8. c语言中的文件流

    一.打开和关闭文件 #include int main( void ) { FILE* pReadFile = fopen( "E:\\mytest.txt", "r&q ...

  9. 文件流StreamReader和StreamWriter的使用

    using (StreamReader sr = new StreamReader(@"C:\Users\shuai\Desktop\文件流读取.txt", Encoding.De ...

随机推荐

  1. test-overflow:ellipsis的应用----转载

    关键字: text-overflow:ellipsis 语法:text-overflow : clip | ellipsis 取值: clip :默认值 .不显示省略标记(...),而是简单的裁切. ...

  2. ndarray对象的使用方法

    ndarray的基本操作 1.索引 基本索引:一维与list完全一致 多维同理 例如: import numpy ndarr1 = numpy.random.randint(0,10.size=5) ...

  3. 设计图与html 对比

    简易打开旧版火狐  网页版火狐添加组件 新版有时也会没有    谷歌是腾讯的

  4. 用VSCode的debugger for chrome插件调试服务器项目的配置方式

    项目放到tomcat服务器启动起来(以tomcat服务器为例). 配置launch 把谷歌浏览器彻底关闭!(要彻底) 打断点 点左侧的调试 点刷新!(这一步也需要)

  5. UVa 11627 - Slalom 二分. oj错误题目 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  6. Cookie中的sessionid与JSONP原理

    一.首先说明一下cookie中的sessionid的作用. 1.cookie只是一些文本内容,多是键值对的形式,是请求头中的一部分 2.http是无连接的 知道这两点,就可以很容易的理解session ...

  7. Linux 驱动——从宏观上掌握基本框架

    一.一个简单的驱动程序实例 led_drv.c 驱动文件: #include <linux/module.h>#include <linux/kernel.h>#include ...

  8. RSA加密解密实现(JAVA)

    1.关于RSA算法的原理解析参考:http://www.ruanyifeng.com/blog/2013/06/rsa_algorithm_part_one.html 2.RSA密钥长度.明文长度和密 ...

  9. 我在MySQL免安装版使用过程中遇到的问题记录

    我的MySQL版本为:mysql-5.7.16-winx64 安装时间为:2016年5月10号 由于是免安装版,下载好压缩文件之后解压到特定目录下,再打开命令行运行几行命令即可. 在一次操作中,发现无 ...

  10. webpack配置(入口出口)

    const path=require('path'); //是node.js的path模块 //单入口,单出口 module.exports={ // 入口文件 entry:{ entry:'./sr ...