title: Xcopy in C# - how to call it?
body: <p>Here I should copy file from nearby local ip address to my local system i have used the following code for copying using the <code>Xcopy</code> command and then launching the process but copying through  Argumentsetting in code mentioned if I execute in command prompt it is copying but through code is not copying please tell what is the issue. Any ideas? what through code not copying.</p>
  
  <pre><code>string Porocess = String.Format("\"{0}\\xcopy.exe\"", Environment.SystemDirectory.ToString());
  
  string SolutionSettings = string.Format("\"\\\\{0}\\C$\\Documents and Settings\\All Users\\Application Data\\Symantec\\Common Client\\settings.bak\"", IPaddress);
  
  string TargetSettings = string.Format("\"C:\\Documents and Settings\\All Users\\Application Data\\Symantec\\settings.bak\"");
  
  string Argumentsetting = /*"\"" +*/ SolutionSettings + " " + TargetSettings + " /Y";// parameters to launch process
  
  int iret1 = LauncProcess(Porocess, Argumentsetting, Environment.SystemDirectory.ToString());
  
  
  
   public static int LauncProcess(string sProcess, string sParams, string sWorkingDir)
          {
              int iRet = 0;
              Process process = null;
  
              try
              {
  
                  ProcessStartInfo startInfo = new ProcessStartInfo();
                  startInfo.FileName = sProcess;
                  startInfo.Arguments = sParams;
                  startInfo.WorkingDirectory = sWorkingDir;
                  startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                  startInfo.CreateNoWindow = true;
  
                  startInfo.UseShellExecute = false;
  
  
                  process = Process.Start(startInfo);
  
                  process.WaitForExit();
  
                  Console.WriteLine("Copy has finished.");
  
                  if (process.HasExited)
                  {
                      Console.WriteLine("Process has exited.");
                      if (process.ExitCode != 0)
                      {
  
                          iRet = 1;
  
                      }
                      else
                      {
                          iRet = 0;
                      }
                  }
                  else
                  {
  
                      iRet = 1;
  
                  }
              }
              catch (Exception ex)
              {
  
                  iRet = 1;
              }
              finally
              {
                  process.Dispose();
              }
              return iRet;
          }
  </code></pre>