首页 > 代码库 > 二进制数组
二进制数组
1 /// <summary> 2 /// 拼接二进制数组 3 /// </summary> 4 /// <param name="buffer1"></param> 5 /// <param name="buffer2"></param> 6 /// <returns></returns> 7 public static byte[] Joint(byte[] buffer1, byte[] buffer2) 8 { 9 byte[] bufferWhole = new byte[buffer1.Length + buffer2.Length]; 10 Buffer.BlockCopy(buffer1, 0, bufferWhole, 0, buffer1.Length); 11 Buffer.BlockCopy(buffer2, 0, bufferWhole, buffer1.Length, buffer2.Length); 12 return bufferWhole; 13 } 14 15 public static byte[] Joint(byte[] buffer1, byte[] buffer2, byte[] buffer3) 16 { 17 return BufferJointer.Joint(BufferJointer.Joint(buffer1, buffer2), buffer3); 18 } 19 20 public static byte[] Joint(byte[] buffer1, byte[] buffer2, byte[] buffer3, byte[] buffer4) 21 { 22 return BufferJointer.Joint(BufferJointer.Joint(buffer1, buffer2, buffer3), buffer4); 23 } 24 25 public static byte[] Joint(byte[] buffer1, byte[] buffer2, byte[] buffer3, byte[] buffer4, byte[] buffer5, byte[] buffer6) 26 { 27 return BufferJointer.Joint(BufferJointer.Joint(buffer1, buffer2, buffer3, buffer4), buffer5, buffer6); 28 }
1 class FileHelper 2 { 3 // 首先引用API 函数 4 5 [DllImport("kernel32.dll")] 6 private static extern IntPtr _lopen(string lpPathName, int iReadWrite); 7 [DllImport("kernel32.dll")] 8 private static extern bool CloseHandle(IntPtr hObject); 9 private const int OF_READWRITE = 2; 10 private const int OF_SHARE_DENY_NONE = 0x40; 11 private readonly IntPtr HFILE_ERROR = new IntPtr(-1); 12 13 14 /// <summary> 15 /// 检查文件是否已经打开 16 /// </summary> 17 /// <param name="strfilepath">要检查的文件路径</param> 18 /// <returns>-1文件不存在,1文件已经打开,0文件可用未打开</returns> 19 public FileStatus VerifyFileIsOpen(string strfilepath) 20 { 21 string vFileName = strfilepath; 22 23 // 先检查文件是否存在,如果不存在那就不检查了 24 if (!File.Exists(vFileName)) 25 { 26 return FileStatus.Inexistence; 27 } 28 29 // 打开指定文件看看情况 30 IntPtr vHandle = _lopen(vFileName, OF_READWRITE | OF_SHARE_DENY_NONE); 31 if (vHandle == HFILE_ERROR) 32 { // 文件已经被打开 33 return FileStatus.Opened; 34 } 35 CloseHandle(vHandle); 36 37 // 说明文件没被打开,并且可用 38 39 return FileStatus.Untapped; 40 } 41 }
二进制数组
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。