Mkdir() public method

Creates a directory on the remot server
public Mkdir ( string dir ) : void
dir string The new directory
return void
        public static void Upload(string filename, string path)
        {
            if (Convert.ToBoolean(ConfigurationManager.AppSettings.Get("EnableSCP")))
            {
                string host = ConfigurationManager.AppSettings.Get("SCPDirectory");
                string user = ConfigurationManager.AppSettings.Get("SCPLogin");
                string password = ConfigurationManager.AppSettings.Get("SCPPassword");
                string newDirectory = "/home/honeybadgers/public_html/Music Files/" + Globals.UserID + "/";

                //Create a new SCP instance
                Scp scp = new Scp(host, user, password);

                scp.Connect();
                scp.Mkdir(newDirectory);

                //Copy a file from local machine to remote SSH server
                scp.To(path, newDirectory + filename);
            }
        }
        private void cmdOK_Click(object sender, EventArgs e)
        {
            String app = projectDirectory;
            CloverleafEnvironment.RemoteServerHost = txtHostName.Text;
            this.Hide();

            String host = txtHostName.Text;
            String user = txtUsername.Text;
            String password = txtPassword.Text;
			Int32 port = FirstOpenPort(host, 60000, 65000);

            String zipDirectory = CloverleafEnvironment.CloverleafAppDataPath;
            String zipFileName = "web." + host + "." + user + "." + DateTime.Now.Ticks.ToString() + ".zip";
            String zipPath = Path.Combine(zipDirectory, zipFileName);
            String scriptPath = Path.Combine(zipDirectory, "web." + host + "." + user + "." + DateTime.Now.Ticks.ToString() + ".sh");
            String closeScriptPath = Path.Combine(zipDirectory, "web." + host + "." + user + "." + DateTime.Now.Ticks.ToString() + ".close.sh");
            String pidPath = Path.GetFileNameWithoutExtension(zipFileName) + ".pid";
            String remoteDirectory = Path.GetFileNameWithoutExtension(zipFileName);

            FastZip fz = new FastZip();

            fz.CreateEmptyDirectories = true;
            fz.RestoreAttributesOnExtract = true;
            fz.RestoreDateTimeOnExtract = true;
            fz.CreateZip(zipPath, app,
                    true, null);

            Scp scp = new Scp(host, user, password);
            scp.Connect();
            if (scp.Connected == false)
            {
                throw new SshTransferException("Couldn't connect to host with SCP.");
            }
            scp.Mkdir("/home/" + user + "/.cloverleaf");
            scp.Put(zipPath, "/home/" + user + "/.cloverleaf/" + zipFileName);
            File.Delete(zipPath);

            String ssh1ArgumentData = "";
            String ssh2ArgumentData = "";

            if (optXSP.Checked == true)
            {
                ssh1ArgumentData = "#! /bin/bash" + "\n" +
                     "cd /home/" + user + "/.cloverleaf" + "\n" +
                     "mkdir " + remoteDirectory + "\n" +
                     "cp " + zipFileName + " " + remoteDirectory + "\n" +
                     "cd " + remoteDirectory + "\n" +
                     "unzip " + zipFileName + " > /dev/null \n" +
                     "xsp2 --nonstop --port " + port.ToString() + "& \n" +
                     "pgrep -l " + user + " -n mono > /home/" + user + "/.cloverleaf/" + pidPath;
                ssh2ArgumentData = "#! /bin/bash" + "\n" +
                     "cd /home/" + user + "/.cloverleaf" + "\n" +
                     "kill `cat " + pidPath + "`" + "\n" +
                     "rm -rf " + Path.GetFileNameWithoutExtension(pidPath) + "*";
            }
            File.WriteAllText(scriptPath, ssh1ArgumentData);
            File.WriteAllText(closeScriptPath, ssh2ArgumentData);

            if (scp.Connected == false)
            {
                throw new SshTransferException("Couldn't connect to host with SCP.");
            }
            scp.Put(scriptPath, "/home/" + user + "/.cloverleaf/" + Path.GetFileName(scriptPath));
            scp.Put(closeScriptPath, "/home/" + user + "/.cloverleaf/" + Path.GetFileName(closeScriptPath));

            String stdOut = "";
            String stdErr = "";

            SshExec ssh = new SshExec(host, user, password);
            ssh.Connect();
            ssh.RunCommand("/bin/bash /home/" + user + "/.cloverleaf/" + Path.GetFileName(scriptPath),
                    ref stdOut, ref stdErr);

            (new RemoteWebServerCloser(Path.GetFileName(closeScriptPath),
                host, user, password)).Show();

            ProcessStartInfo wwwProcInfo = new ProcessStartInfo();
            wwwProcInfo.FileName = "http://" + host + ":" + port.ToString();
            wwwProcInfo.UseShellExecute = true;
            Process wwwProc = new Process();
            wwwProc.StartInfo = wwwProcInfo;
            wwwProc.Start();
        }
        private void cmdOK_Click(object sender, EventArgs e)
        {
            String app = Path.Combine(solutionDirectory, (String) lstLaunchItems.SelectedItem);
            CloverleafEnvironment.RemoteServerHost = txtHostName.Text;
            this.Hide();

            String host = txtHostName.Text;
            String user = txtUsername.Text;
            String password = txtPassword.Text;

            String zipDirectory = CloverleafEnvironment.CloverleafAppDataPath;
            String zipFileName = host + "." + user + "." + DateTime.Now.Ticks.ToString() + ".zip";
            String zipPath = Path.Combine(zipDirectory, zipFileName);
            String scriptPath = Path.Combine(zipDirectory, DateTime.Now.Ticks.ToString() + ".sh");
            String remoteExecutable = Path.GetFileName(app);
            String remoteDirectory = Path.GetFileNameWithoutExtension(zipFileName);

            FastZip fz = new FastZip();

            fz.CreateEmptyDirectories = true;
            fz.RestoreAttributesOnExtract = true;
            fz.RestoreDateTimeOnExtract = true;
            fz.CreateZip(zipPath, Path.GetDirectoryName(app),
                    true, null);

            ProcessStartInfo xInfo = new ProcessStartInfo();
            xInfo.FileName = CloverleafEnvironment.XPath;
            xInfo.Arguments = "-ac -internalwm";
            Process xProcess = new Process();
            xProcess.StartInfo = xInfo;
            xProcess.Start();

            Scp scp = new Scp(host, user, password);
            scp.Connect();
            if (scp.Connected == false)
            {
                throw new SshTransferException("Couldn't connect to host with SCP.");
            }
            scp.Mkdir("/home/" + user + "/.cloverleaf");
            scp.Put(zipPath, "/home/" + user + "/.cloverleaf/" + zipFileName);
            File.Delete(zipPath);
            
            String ssh1ArgumentData = "#! /bin/bash" + "\n" +
                "export DISPLAY=" + cboLocalIPs.SelectedItem.ToString() + ":0.0" + "\n" +
                "cd /home/" + user + "/.cloverleaf" + "\n" +
                "mkdir " + remoteDirectory + "\n" +
                "cp " + zipFileName + " " + remoteDirectory + "\n" +
                "cd " + remoteDirectory + "\n" +
                "unzip " + zipFileName + " > /dev/null \n" +
                "mono " + remoteExecutable + "\n" +
                "cd /home/" + user + "/.cloverleaf" + "\n" +
                "rm " + zipFileName + "\n" +
                "rm -rf " + remoteDirectory + "\n" +
                "rm /home/" + user + "/.cloverleaf/" + Path.GetFileName(scriptPath);
            File.WriteAllText(scriptPath, ssh1ArgumentData);

            if (scp.Connected == false)
            {
                throw new SshTransferException("Couldn't connect to host with SCP.");
            }
            scp.Put(scriptPath, "/home/" + user + "/.cloverleaf/" + Path.GetFileName(scriptPath));

            String stdOut = "";
            String stdErr = "";

            SshExec ssh = new SshExec(host, user, password);
            ssh.Connect();
            ssh.RunCommand("/bin/bash /home/" + user + "/.cloverleaf/" + Path.GetFileName(scriptPath),
                    ref stdOut, ref stdErr);

            (new RemoteStdOutDisplay(stdOut, stdErr)).Show();
        }