Esempio n. 1
0
        private void createDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Renaming r = new Renaming();

            r.f    = this;
            r.Text = "New directory";
            r.ShowDialog();
            if (name == string.Empty)
            {
                return;
            }
            for (int i = 0; i < remoteLV.Items.Count; i++)
            {
                if (name == remoteLV.Items[i].Text)
                {
                    MessageBox.Show("The directory with such a name already exists.", "Error", MessageBoxButtons.OK);
                    return;
                }
            }
            lock (currRemoteDir)
            {
                try
                {
                    FtpWebRequest Request = (FtpWebRequest)WebRequest.Create(currRemoteDir + name);
                    Request.Credentials = new NetworkCredential(login, password);
                    Request.Method      = WebRequestMethods.Ftp.MakeDirectory;
                    Request.Proxy       = null;
                    FtpWebResponse Responce = (FtpWebResponse)Request.GetResponse();
                    Stream         stream   = Responce.GetResponseStream();
                    Responce.Close();
                    name = string.Empty;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
                }
            }
        }
Esempio n. 2
0
 private void renameToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Renaming r = new Renaming();
     r.f = this;
     r.Text = "Renaming";
     r.ShowDialog();
     if (name == string.Empty)
         return;
     for (int i = 0; i < remoteLV.Items.Count; i++)
     {
         if (name == remoteLV.Items[i].Text)
         {
             MessageBox.Show("The directory or file with such a name already exists.", "Error", MessageBoxButtons.OK);
             return;
         }
     }
     lock (currRemoteDir)
     {
         try
         {
             FtpWebRequest Request = (FtpWebRequest)WebRequest.Create(currRemoteDir + remoteLV.FocusedItem.Text);
             Request.Credentials = new NetworkCredential(login, password);
             Request.Method = WebRequestMethods.Ftp.Rename;
             Request.Proxy = null;
             Request.RenameTo = name;
             FtpWebResponse Responce = (FtpWebResponse)Request.GetResponse();
             name = string.Empty;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
         }
     }
 }