标签:文件写入 ttf def using get str http open ref
原文:https://blog.csdn.net/qq_41209575/article/details/89178020
3.文件流
3.1文件流文字形式读取
byte[] bytsize = new byte[1024 * 1024 * 5]; using (FileStream stream = new FileStream(path, FileMode.OpenOrCreate,FileAccess.ReadWrite)) { while (true) { int r = stream.Read(bytsize, 0, bytsize.Length); //如果读取到的字节数为0,说明已到达文件结尾,则退出while循 if (r == 0) { break; } string str = Encoding.Default.GetString(bytsize, 0, r); Console.WriteLine(str); } }
3.2文件流文字形式写入
string str = "今天天气好晴朗,处处好风光"; byte[] buttf = Encoding.Default.GetBytes(str); //文件流的写入 using (FileStream fscreat = new FileStream(path, FileMode.Append, FileAccess.Write)) { fscreat.Write(buttf, 0, buttf.Length); }
3.3文件流视频形式复制
byte[] bytsize = new byte[1024 * 1024 * 5]; string videoPath = @"C:\Users\Administrator\Desktop\1、练习1-3.avi"; string videoNewPath = @"C:\Users\Administrator\Desktop\1.avi"; //创建读取流 using (FileStream fsread=new FileStream(videoPath,FileMode.Open,FileAccess.Read)) { //创建写入流 using (FileStream fswrite=new FileStream(videoNewPath,FileMode.OpenOrCreate,FileAccess.Write)) { while (true) { //返回实际读取到的字节 int r = fsread.Read(bytsize, 0, bytsize.Length); //当字节位0的时候 证明已经读取结束 if(r==0){ break; } fswrite.Write(bytsize,0,r); } } }
标签:文件写入 ttf def using get str http open ref
原文地址:https://www.cnblogs.com/zhang1f/p/11761311.html