Beispiel #1
0
        void renameItem_Click(object sender, EventArgs e)
        {
            ToolStripItem clickedItem   = sender as ToolStripItem;
            string        strRemotePath = "";

            if (clickedItem.Text.Equals("Rename"))
            {
                strRemotePath = remoteTreeView.SelectedNode.FullPath;
                using (RenameForm renameForm = new RenameForm())
                {
                    if (renameForm.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            Cursor.Current = Cursors.WaitCursor;
                            string strNewFileName = renameForm.newFileName;
                            Ftp    ftpClient      = new Ftp(strHost, strUser, strPass);
                            ftpClient.rename(strRemotePath, strNewFileName);
                            ftpClient = null;
                            populateRemoteNode(remoteTreeView.SelectedNode.Parent);
                            remoteTreeView.SelectedNode.Parent.Expand();
                            Cursor.Current = Cursors.Default;
                            MessageBox.Show("File Rename Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        catch (Exception ex)
                        {
                            Cursor.Current = Cursors.Default;
                            MessageBox.Show("File Rename Unsuccessful\n" + ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        void renameItem_Click(object sender, EventArgs e)
        {
            ToolStripItem clickedItem = sender as ToolStripItem;
            string strRemotePath ="";

            if (clickedItem.Text.Equals("Rename"))
            {
                strRemotePath = remoteTreeView.SelectedNode.FullPath;
                using (RenameForm renameForm = new RenameForm())
                {
                    if (renameForm.ShowDialog() == DialogResult.OK)
                    {

                        try
                        {
                            Cursor.Current = Cursors.WaitCursor;
                            string strNewFileName = renameForm.newFileName;
                            Ftp ftpClient = new Ftp(strHost, strUser, strPass);
                            ftpClient.rename(strRemotePath, strNewFileName);
                            ftpClient = null;
                            populateRemoteNode(remoteTreeView.SelectedNode.Parent);
                            remoteTreeView.SelectedNode.Parent.Expand();
                            Cursor.Current = Cursors.Default;
                            MessageBox.Show("File Rename Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        catch (Exception ex)
                        {
                            Cursor.Current = Cursors.Default;
                            MessageBox.Show("File Rename Unsuccessful\n" + ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }