private void pathTextBox_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Enter) { return; } string enteredPath = pathTextBox.Text; eFileType fileType = FileManagerUtils.GetCurrentPathType(enteredPath); if (fileType == eFileType.Folder) { m_currentPath = enteredPath; fillDataGridView(Directory.GetFileSystemEntries(enteredPath, "*", SearchOption.TopDirectoryOnly)); } else if (fileType == eFileType.File) { System.Diagnostics.Process.Start(enteredPath); } else // TODO web site should work also from url bar. { MessageBox.Show("Windows can't find '" + enteredPath + "'. Check the spelling and try again.", "File Explorer", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void Perform(eActionType i_ActionType, string i_OriginPath, string io_DestinationPath) { if (io_DestinationPath == Path.GetDirectoryName(i_OriginPath) && i_ActionType == eActionType.Move) { return; } ProcessDestinationPath(i_OriginPath, ref io_DestinationPath); switch (FileManagerUtils.GetCurrentPathType(i_OriginPath)) { case eFileType.File: handleFileType(i_ActionType, i_OriginPath, io_DestinationPath); break; case eFileType.Folder: handleFolderType(i_ActionType, i_OriginPath, io_DestinationPath); break; case eFileType.Invalid: break; case eFileType.LogicalDrive: MessageBox.Show("You cannot move logical drive.", "Windows Explorer", MessageBoxButtons.OK, MessageBoxIcon.Error); break; default: throw new ArgumentOutOfRangeException(); } }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { setStacks(); eFileType fileType = FileManagerUtils.GetCurrentPathType(m_currentPath); if (fileType == eFileType.Folder || fileType == eFileType.LogicalDrive) { fillDataGridView(Directory.GetFileSystemEntries(m_currentPath, "*", SearchOption.TopDirectoryOnly)); } else if (fileType == eFileType.File) { System.Diagnostics.Process.Start(m_currentPath); } }
private static void ProcessDestinationPath(string i_OriginPath, ref string io_DestinationPath) { if (FileManagerUtils.GetCurrentPathType(io_DestinationPath) != eFileType.LogicalDrive) { io_DestinationPath += "\\" + Path.GetFileName(i_OriginPath); } else { io_DestinationPath += Path.GetFileName(i_OriginPath); } if (i_OriginPath.Equals(io_DestinationPath)) { while (File.Exists(io_DestinationPath) || Directory.Exists(io_DestinationPath)) { io_DestinationPath = Path.GetDirectoryName(io_DestinationPath) + Path.GetFileNameWithoutExtension(io_DestinationPath) + " - Copy" + Path.GetExtension(i_OriginPath); } } }