private void tsmi_item_rename_Click(object sender, EventArgs e) { string newName = IOComm.ShowRenameDialog(this, IOComm.PathCombin(_CurrentPath, _CurrentName)); if (string.IsNullOrWhiteSpace(newName)) { return; } _CurrentName = Path.GetFileName(newName); _CurrentRow.Cells[nameColumn.Index].Value = _CurrentName; }
protected override void OkButton_Click(object sender, EventArgs e) { string sp = null; #region 未输入保存文件名 if (string.IsNullOrWhiteSpace(SaveName)) { MessageBox.Show(this, "请输入保存文件名"); nameComboBox.Focus(); return; } #endregion #region 输入的文件名存在非法字符 else if (PathHelper.IsNameInvalidCharContained(SaveName)) { MessageBox.Show(this, "不合法的文件名, 请勿输入以下非法字符 < > / \\ | ? * \" : 等"); nameComboBox.Focus(); return; } #endregion else { #region 获取文件完整路径 // 获取文件拓展名 string sType = _CurrentExts[0] == ".*" ? string.Empty : _CurrentExts[0]; // 判断当前有没有选中一个文件夹 // 未选中文件或文件夹 if (string.IsNullOrWhiteSpace(_CurrentName)) { sp = IOComm.PathCombin(_CurrentPath, SaveName + sType); } else { sp = IOComm.PathCombin(_CurrentPath, Path.GetFileNameWithoutExtension(_CurrentName) + sType); } #endregion } #region 判断是否存在同名文件 if (PathHelper.IsExisted(sp)) { string inf = string.Format("存在同名文件或文件夹,是否继续?\r\npath = {0}", sp); DialogResult dr = MessageBox.Show(this, inf, "文件名冲突", MessageBoxButtons.YesNo); if (dr != DialogResult.Yes) { nameComboBox.Focus(); return; } } #endregion this.InputPath = sp; this.DialogResult = DialogResult.OK; this.Close(); }
protected override void _Tsmi_item_Open_Click(object sender, EventArgs e) { if (_CurrentFf == PathType.File) { OkButton_Click(sender, e); } else if (_CurrentFf == PathType.Floder) { loadDirectory(IOComm.PathCombin(_CurrentPath, _CurrentName)); } }
protected override void OkButton_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(nameComboBox.Text)) { MessageBox.Show(this, "您还未选择任何文件,请选择要打开的文件"); return; } string _path = string.Empty; List <string> _ps = new List <string>(); string[] _names = nameComboBox.Text.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string item in _names) { if (string.IsNullOrWhiteSpace(item)) { continue; } _path = IOComm.PathCombin(_CurrentPath, item); if (File.Exists(_path)) { _ps.Add(_path); } else { string inf = string.Format("系统找不到文件 < {0} >\r\npath = {1}", item, _path); MessageBox.Show(inf); return; } } if (_ps.Count == 0) { MessageBox.Show(this, "您选择的文件的个数为0,至少选择一个文件,请重新选择,退出请点击取消"); return; } else { this.InputPath = string.Empty; foreach (string item in _ps) { this.InputPath += item; this.InputPath += "|"; } this.InputPath = this.InputPath.Remove(this.InputPath.Length - 1, 1); this.InputPaths.Clear(); this.InputPaths.AddRange(_ps); this.DialogResult = DialogResult.OK; this.Close(); } }
protected override void _Tsmi_item_Open_Click(object sender, EventArgs e) { string tmp = IOComm.PathCombin(_CurrentPath, _CurrentName); if (File.Exists(tmp)) { System.Diagnostics.Process.Start(tmp); } else if (Directory.Exists(tmp)) { loadDirectory(tmp); } else { MessageBox.Show(this, "系统找不到以下路径:\r\nPath = " + tmp, null, MessageBoxButtons.OK); } }
private void tsmi_item_delete_Click(object sender, EventArgs e) { if (Forms.MessageBox.Show(this, string.Format("即将永久删除 <{0}> 个文件(夹),是否继续?", dataGridView.SelectedRows.Count), "删除提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } foreach (DataGridViewRow item in dataGridView.SelectedRows) { string delpath = IOComm.PathCombin(_CurrentPath, item.Cells[nameColumn.Index].Value.ToString()); try { PathHelper.Delete(delpath); dataGridView.Rows.Remove(item); } catch (Exception ex) { MessageBox.Show(this, string.Format("未删除 <{0}>,失败原因\r\n{1}", delpath, ex.Message), "删除失败", MessageBoxButtons.OK); } } }
private void tsmi_item_attribute_Click(object sender, EventArgs e) { Windows.Explore.ShowPropertiesDialog(IOComm.PathCombin(_CurrentPath, _CurrentName)); }