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