private void BtnDownloadTRMM_Click(object sender, EventArgs e)
        {
            string driveLetter;
            string ProjectFolderName;

            if (TxtProjectName.Text == "")
            {
                ProjectFolderName = "TRMMData_" + DateTime.Now.ToString("yyyyMMddTHHmmss");
            }
            ProjectFolderName = TxtProjectName.Text;

            Process cmd = new Process();

            cmd.StartInfo.FileName = "cmd.exe";
            cmd.StartInfo.RedirectStandardInput  = true;
            cmd.StartInfo.RedirectStandardOutput = true;
            cmd.StartInfo.CreateNoWindow         = true;
            cmd.StartInfo.UseShellExecute        = false;
            cmd.Start();

            driveLetter = Path.GetPathRoot(Environment.CurrentDirectory);
            string CopyCmd = "copy wget.exe " + driveLetter;

            cmd.StandardInput.WriteLine("mkdir " + driveLetter + ProjectFolderName); //make project folder
            cmd.StandardInput.WriteLine(CopyCmd);                                    //copy wget.exe from degug folder of program to root directory
            cmd.StandardInput.WriteLine("cd\\");                                     //root directory

            cmd.StandardInput.WriteLine("cd " + ProjectFolderName);                  //go to project folder
            //MessageBox.Show(driveLetter);

            cmd.StandardInput.WriteLine("mkdir Cookies Data"); //make cookies and data folder in project folder

            cmd.StandardInput.WriteLine("cd Cookies");         //go to cookies folder
            cmd.StandardInput.WriteLine("NUL > .urs_cookies"); //create cookies file in cookies folder

            string Cookies_loc = driveLetter + ProjectFolderName + "\\Cookies\\.urs_cookies";
            //MessageBox.Show(loc);

            //string downloadTrmmData = "wget --load-cookies " + Cookies_loc + " --save-cookies " + Cookies_loc + " --auth-no-challenge=on --keep-session-cookies --user=username --password=password --content-disposition -i " + textBox1.Text;
            string usrnm            = TxtUsername.Text;
            string passwrd          = TxtPassword.Text;
            string downloadTrmmData = "wget --load-cookies " + Cookies_loc + " --save-cookies " + Cookies_loc + " --auth-no-challenge=on --keep-session-cookies --user="******" --password="******" --content-disposition -i " + TxtDownloadLinkList.Text;

            //MessageBox.Show(downloadTrmmData);

            cmd.StandardInput.WriteLine("cd\\"); //root directory
            //cmd.StandardInput.WriteLine("cd " + ProjectFolderName); //go to project folder
            string cmd3_1    = "copy wget.exe " + driveLetter + ProjectFolderName + "\\Data";
            string DeleteCmd = "del wget.exe";

            //MessageBox.Show(cmd3_1);
            cmd.StandardInput.WriteLine(cmd3_1);                               //copy wget to Data Folder
            cmd.StandardInput.WriteLine(DeleteCmd);                            //copy wget to Data Folder
            cmd.StandardInput.WriteLine("cd " + ProjectFolderName + "\\Data"); //go to Data Folder

            Application.DoEvents();
            TxtMessage.AppendText(DateTime.Now.ToString("hh:mm:ss") + "  ==> Please Wait....Downloading TRMM Data....May take several minutes depending on data and Internet Speed");
            TxtMessage.AppendText(Environment.NewLine);
            cmd.StandardInput.WriteLine(downloadTrmmData); //download trmmData

            //driveLetter = Path.GetPathRoot(Environment.CurrentDirectory);
            //MessageBox.Show(driveLetter);

            cmd.StandardInput.Flush();
            cmd.StandardInput.Close();
            cmd.WaitForExit();
            Console.WriteLine(cmd.StandardOutput.ReadToEnd());

            //MessageBox.Show("Completed");
            DownloadedFolderPath = driveLetter + ProjectFolderName + "\\Data";
            TxtMessage.AppendText(DateTime.Now.ToString("hh:mm:ss") + "  ==> Download Completed!");
            TxtMessage.AppendText(Environment.NewLine);
            TxtMessage.AppendText(DateTime.Now.ToString("hh:mm:ss") + "  ==> Downloaded Folder :  " + driveLetter + ProjectFolderName + "\\Data");
            TxtMessage.AppendText(Environment.NewLine);
            TxtMessage.AppendText(DateTime.Now.ToString("hh:mm:ss") + "  ==> Click open to open the folder containing downloaded data");
            TxtMessage.AppendText(Environment.NewLine);
        }
Example #2
0
 public void OutputMessage(string message)
 {
     TxtMessage.AppendText(message + Environment.NewLine + Environment.NewLine);
 }