// 填充报文的头部, 返回报文的总长度 public int FillReq(byte[] sendData, int flag, string strReq) { CSynFiles.ApendByte(sendData, 4, flag); // 填充flag 标记 int extLen = CSynFiles.ApendByte(sendData, 12, strReq); CSynFiles.ApendByte(sendData, 8, extLen); CSynFiles.ApendByte(sendData, 0, extLen + 12); return(extLen + 12); }
private void Main_Form_Load(object sender, EventArgs e) { _synFiles = new CSynFiles(this, _dbFile); // 同步文件的类 Random ran = new Random((int)DateTime.Now.Ticks); this.lbx_linux_dirs.HorizontalScrollbar = true; // 连接服务器 //Connnet(); // 初试话listView ColumnHeader ch = new ColumnHeader(); ch.Text = "文件名称"; //设置列标题 ch.Width = 400; //设置列宽度 ch.TextAlign = HorizontalAlignment.Left; //设置列的对齐方式 this.lvTask.Columns.Add(ch); //将列头添加到ListView控件。 this.lvTask.Columns.Add("linux目录", 500, HorizontalAlignment.Left); LoadComBox(); // 加载任务 // _dbFile.LoadTask(this.lvTask); _dbFile.LoadDir(this.lbx_linux_dirs); // 初始化树形目录 this.cmbDirs.Text = _dbFile.GetWindowRootPath(); TreeNode root = new TreeNode(); //根目录名称 root.Text = "目录"; //根目录路径 SynCommon.GetFiles(this.cmbDirs.Text, root, lvTask); tvFiles.Nodes.Clear(); foreach (TreeNode n in root.Nodes) { tvFiles.Nodes.Add(n); } _dbFile.SetWindowRootPath(this.cmbDirs.Text); // 加载当前同步目录 _dbFile.LoadSynDirectory(); CSynDirectory synDir = _dbFile._synDirectory; // 目录同步 foreach (CSynDirectoryItem item in synDir.lsItems) { CFileWatcher fileWatch = new CFileWatcher(this, item.win_dir, item.linux_dir); fileWatch._allFileWatch = _lsFileWatches; _lsFileWatches.Add(fileWatch); } }
public CFileWatcher(Main_Form mainForm, string winRootPath, string linuRootPath) { _mainForm = mainForm; _synFiles = new CSynFiles(mainForm, mainForm._dbFile); // 连接类 _linux_root_path = linuRootPath; _watcher.Path = winRootPath; _watcher.EnableRaisingEvents = false; // _watcher.Filter = "*.h|*.cpp"; _watcher.Changed += new FileSystemEventHandler(Changed); _watcher.Created += new FileSystemEventHandler(Created); _watcher.Deleted += new FileSystemEventHandler(Deleted); _watcher.Renamed += new RenamedEventHandler(Renamed); _watcher.NotifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastWrite; _watcher.IncludeSubdirectories = true; // 同步的时候需要排除的目录列表 _lsExcludeDir.Add(@"trunk\apps\penguin_game\common\jce"); _lsExcludeDir.Add(@".svn"); _lsExcludeDir.Add(@".git"); }