UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Start Argument With Spaces    
 
   
Ueberyak
post Dec 12 2014, 05:45 PM
Post#1



Posts: 433
Joined: 13-April 04



I am calling an outside process from C#. Everything is working except for the argument which has spaces in it. I know it needs to be wrapped in quotes in some way but I have not been able to get it to work. The problematic value is oRoot, which has a value of "/ABC Customer Data/Test/RootTest".



CODE
                string oCustomerID = comboBox1.SelectedItem.ToString();
                string oProfile = "";
                string oServer = "";
                string oPort = "";
                string oLogin = "";
                string oPassword = "";
                string oLetter = "";
                string oRoot = "";
                string oOpen = "";
                string oTimeout = "";
                string oReconnectNumber = "";
                string oReconnectTime = "";


                DataTable table = new DataTable();
                DataTableReader reader = new DataTableReader(driveProfileTableAdapter.GetData(oCustomerID));
                table.Load(reader);
                foreach (DataRow row in table.Rows)
                {
                    oProfile = row["Profile"].ToString();
                    oServer = row["Server"].ToString();
                    oPort = row["Port"].ToString();
                    oLogin = row["Username"].ToString();
                    oPassword = row["Password"].ToString();
                    oLetter = row["Letter"].ToString();
                    oRoot = "/root:" + row["Root"].ToString();
                    oOpen = row["OnOpen"].ToString();
                    oTimeout = row["TimeOut"].ToString();
                    oReconnectNumber = row["ReconnectNumber"].ToString();
                    oReconnectTime = row["ReconnectTime"].ToString();
                }

                System.Diagnostics.Process process = new System.Diagnostics.Process();
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                startInfo.FileName = "cmd.exe";
                startInfo.Arguments = "/c sftpnetdrive.exe new /profile:" + oProfile + " /server:" + oServer + " /Port:" + oPort + " /Login:" + oLogin + " /password:" + oPassword + " /letter:" + oLetter + " /root:" + oRoot + " /open:" + oOpen + " /timeout:" + oTimeout + " /reconnect:" + oReconnectNumber + "," + oReconnectTime;
                process.StartInfo = startInfo;
                process.Start();
Go to the top of the page
 
Ueberyak
post Dec 15 2014, 02:13 PM
Post#2



Posts: 433
Joined: 13-April 04



I got it.

I changed the following line from

CODE
" /root:" + oRoot + " /open:" + oOpen


to

CODE
" /root:\"" + oRoot + "\" /open:" + oOpen
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    14th December 2017 - 10:17 AM