C# 读取文件流
1 /// <summary> 2 /// 读取文件流 3 /// </summary> 4 public static byte[] ReadFileStream(string filePath) 5 { 6 Stream source = null; 7 byte[] readBytes = null; 8 try 9 { 10 // 读取文件 11 source = new FileStream(filePath, FileMode.Open, FileAccess.Read); 12 readBytes = new byte[source.Length]; 13 source.Read(readBytes, 0, (int)source.Length); 14 } 15 catch (Exception) 16 { 17 throw; 18 } 19 finally 20 { 21 if (source != null) 22 { 23 source.Close(); 24 } 25 } 26 return readBytes; 27 }

浙公网安备 33010602011771号