private void cmDeleteFile_Click(object sender, EventArgs e) { if (MessageBox.Show("確定刪除所選檔案?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes) { return; } if (treeDir.SelectedNode == null) { return; } TreeNode currentNode = treeDir.SelectedNode; string path = PathHelper.GetNodeFullName(currentNode); try { _moduleHandler.DeletePath(path); } catch (Exception ex) { MessageBox.Show("刪除伺服器檔案發生錯誤 : \n" + ex.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string filepath = PathHelper.CombineLocalPath(_moduleHandler.LocalPath, path); try { if (Directory.Exists(filepath)) { Directory.Delete(filepath, true); } else if (File.Exists(filepath)) { File.Delete(filepath); } } catch (Exception ex) { MessageBox.Show("刪除本機檔案發生錯誤 : \n" + ex.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } treeDir.Nodes.Remove(treeDir.SelectedNode); }
public void Upload() { string msg = "確定要「上傳」差異檔案到主機?這會覆蓋主機的檔案。"; if (MessageBox.Show(msg, "檔案同步", MessageBoxButtons.YesNo) == DialogResult.No) { return; } if (!ModuleHandler.LocalPathExists) { return; } string moduleName = ModuleHandler.Name; ModifierCollection list = ModuleHandler.CheckUploadModifier(); List <UploadFile> files = new List <UploadFile>(); XmlHelper req = new XmlHelper(); req.AddElement(".", "ModuleName", moduleName); foreach (Modifier m in list) { if (m.ActionMode == ActionType.SendDelete) { ModuleHandler.DeletePath(m.Path); } else if (m.ActionMode == ActionType.UpdateFile && m.FileMode == FileType.Directory) { req.AddElement(".", "Path", m.Path); } else if (m.ActionMode == ActionType.UpdateFile && m.FileMode == FileType.File) { UploadFile f = new UploadFile(); FileInfo file = new FileInfo(m.Path); f.File = file; f.ServerPath = PathHelper.GetServerPath(ModuleHandler.LocalPath, m.Path); files.Add(f); } } if (req.GetElement("Path") != null) { MainForm.LoginArgs.SendModuleRequest("PrepareDirectory", new Envelope(req)); } if (files.Count > 0) { string ftp = PathHelper.GetFtpPath(MainForm.LoginArgs.FtpURL, MainForm.LoginArgs.GreeningID, moduleName); ProgressForm pf = new ProgressForm(files.ToArray(), ftp, MainForm.LoginArgs.FtpUser, MainForm.LoginArgs.FtpPassword); pf.ShowDialog(); } ModuleHandler.Reload(); //if (NeedUploadChanged != null) // NeedUploadChanged.Invoke(this, new NeedStatusEventArgs(false)); FileEditable fe = CurrentEditor as FileEditable; FileUIEditor ui = fe.Editor as FileUIEditor; ui.Reload(); }