mardi 29 juin 2021

Method not executing if statement in C#

I have a method to start a process and if the output contains a certain string it will execute a different method, but it doesn't seem to be executing the if statement

    public static void installerD(String[] args)
    {
        Parallel.For(0, args.Length, (i) =>
          {
              Console.WriteLine($"Installing {args[i]}");

              String repoPath = $@" Repositories/repo{i}";

              ProcessStartInfo p = new ProcessStartInfo();
              p.FileName = gitcommand;
              p.Arguments = "clone " + args[i] + $@" Repositories/repo{i}";
              p.UseShellExecute = false;
              p.RedirectStandardOutput = true;

              using (Process run = Process.Start(p))
              {
                  using (StreamReader Reader = run.StandardOutput)
                  {
                      String ifmethod = Reader.ToString();
                      
                      if (ifmethod.Contains("already exists"))
                      {
                          gitCheck(repoPath, args[i]);
                      }
                  }
              }

          });
    }

Aucun commentaire:

Enregistrer un commentaire