public void ctxtDownloadContext_Cancel_Click(object sender, EventArgs e)
        {
            ListView lstDownloads = rcloneExplorer.myform.Controls.Find("lstDownloads", true)[0] as ListView;
            //find PID for current transfer
            string PID = lstDownloads.SelectedItems[0].SubItems[0].Text;
            //get filename
            string FN = lstDownloads.SelectedItems[0].SubItems[1].Text;
            //get progress of file (cant cancel 100%)
            string FP = lstDownloads.SelectedItems[0].SubItems[2].Text;

            //if the file process is 100%, it's done
            if (FP == "Done!" || FP == "100%" || !miscContainer.ProcessExists(Convert.ToInt32(PID)))
            {
                MessageBox.Show("ERR: Transfer already completed");
            }
            //file is not 100% and the process is still active
            else
            {
                //kill PID
                miscContainer.KillProcessAndChildren(Convert.ToInt32(PID));
                //if the file exists, delete it
                if (System.IO.File.Exists(FN))
                {
                    System.IO.File.Delete(FN);
                }
                //mark list entry as cancelled
                lstDownloads.SelectedItems[0].SubItems[0].Text = "Cancelled";
            }
        }
Пример #2
0
 private void menuStripFile_QuitKill_Click(object sender, EventArgs e)
 {
     //go through every rclone download process on record
     foreach (string[] entry in downloadsHandler.downloading)
     {
         //get process ID
         int PID = Convert.ToInt32(entry[0]);
         //check if the process is still active
         if (miscContainer.ProcessExists(PID))
         {
             //kill PID
             miscContainer.KillProcessAndChildren(PID);
         }
     }
     //close app
     Environment.Exit(0);
 }