// 文件修改被触发两次 public void Changed(object source, FileSystemEventArgs e) { _mainForm.Log("id[" + id + "]文件改变事件处理逻辑 " + e.ChangeType + e.FullPath); if (!IsSyn(e.FullPath)) { return; } string linuxPath = e.FullPath.Replace(GetWindowsPath(), _linux_root_path); linuxPath = linuxPath.Replace("\\", "/"); int index = linuxPath.LastIndexOf("/"); if (index >= 0) { linuxPath = linuxPath.Substring(0, index); } _synFiles.SynFile(e.FullPath, linuxPath); Log("id[" + id + "]同步文件:" + e.FullPath + "->" + linuxPath); Log(Environment.NewLine); Log(Environment.NewLine); }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <param name="i"></param> /// <param name="count">0 不限制长度, 最大可填充的报文大小</param> /// <param name="str"></param> /// 返回最大填充的位置,从零开始 static public int ApendByte(byte[] data, int i, int count, string str) { byte[] tmpData = Encoding.UTF8.GetBytes(str); if (i + tmpData.Length > data.Length) { _mainForm.Log("数据超出范围限制"); throw new Exception(" 数据超出范围限制"); } if (tmpData.Length > count) { _mainForm.Log("数据太长,无法填充。"); throw new Exception(" 数据太长,无法填充"); } int j = 0; if (count != 0) { for (j = 0; j < tmpData.Length && j < count; j++) { data[i + j] = tmpData[j]; } return(i + j); } else { for (j = 0; j < tmpData.Length; j++) { data[i + j] = tmpData[j]; } return(i + j); } }