在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
//================二进制相关转换类============== #region 将文件转换为二进制数组 /// <summary> /// 将文件转换为二进制数组 /// </summary> /// <param name="FilePath">文件完整路径</param> /// <returns>二进制数组</returns> public static byte[] FileToBinary(string FilePath) { byte[] Buffer = null; if (Utils.FilesHelper.FileExists(FilePath) && System.IO.Path.HasExtension(FilePath)) { FileStream stream = new FileInfo(FilePath).OpenRead(); Buffer = new byte[stream.Length]; stream.Read(Buffer, 0, Convert.ToInt32(stream.Length)); } return Buffer; } #endregion #region 二进制数组转为文件 /// <summary> /// 二进制数组转为文件 /// </summary> /// <param name="FilePath">转到的文件完整路径</param> /// <param name="Buffer">二进制数组</param> /// <returns>转换是否成功</returns> public static bool BinaryToFile(string FilePath, byte[] Buffer) { bool flag = false; FileStream fstream = File.Create(FilePath, Buffer.Length); try { fstream.Write(Buffer, 0, Buffer.Length); flag = true; } catch (Exception) { } finally { fstream.Close(); } return flag; } #endregion
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论