{
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. noip模拟ernd

    [题目背景]解决了第一题之后,你打开了第二题.这是一道关于树的题目,你很快想出了一个复杂度和树的直径有关的算法,可以通过所有的数据.不过,你的做法常数似乎有点大.为了更好地卡常,你决定构造一些数据来检 ...

  2. vscode 创建.net core mvc

    cd 进一个文件夹 1,创建一个sln 工程文件  [ dotnet new sln -n Demo1 ] 2,创建一个mvc项目 [ dotnet new mvc -n Demo1.Web ] 3, ...

  3. 使用IntelliJ IDEA开发java web

    前言:由于本人接触java语言时间还比较短,IDE工具eclipse还比较熟悉点,想试试用IntelliJ IDEA来开发java web项目来练练手! 一.下载安装篇 1.安装IntelliJ ID ...

  4. eureka 服务注册与发现

    1.创建父工程来管理依赖包 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:/ ...

  5. mybatis xml配置文件模版

    mybatis xml配置文件模版 1.mybatis核心配置文件书写(SqlMapConfig.xml) <?xml version="1.0" encoding=&quo ...

  6. Python 进程池的异步方法

    import time from multiprocessing import Process,Pool def f1(n): time.sleep(0.5) # print(n) return n* ...

  7. 剑指Offer 24. 二叉树中和为某一值的路径 (二叉树)

    题目描述 输入一颗二叉树的跟节点和一个整数,打印出二叉树中结点值的和为输入整数的所有路径.路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径.(注意: 在返回值的list中,数组长度大 ...

  8. Linux 驱动——Led驱动1

    led_drv.c驱动文件: #include <linux/module.h>#include <linux/kernel.h>#include <linux/init ...

  9. Power BI和 Visio 集成优缺点

    Power BI 的 Visio 自定义视觉,这个功能是非常值得让人兴奋的,小悦相信这是一个非常重要的开发,不仅适用于 Visio,也适用于Power BI.现在已经有越来越多的可视化,它们以更简洁的 ...

  10. MySQL - 常见的存储引擎

    数据库存储引擎是数据库底层软件组织,数据库管理系统(DBMS)使用数据引擎进行创建.查询.更新和删除数据,不同的存储引擎... 存储引擎 数据库存储引擎: 是数据库底层软件组织,数据库管理系统(DBM ...