Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. invalid path using process.start method

invalid path using process.start method

Scheduled Pinned Locked Moved C#
helpquestion
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stephan_007
    wrote on last edited by
    #1

    hi everyone! i do have a problem, which occours on some machines but not on every machine: when using the process.start method, it throws the exception the path is invalid.

    System.Diagnostics.Process process = Process.Start(startInfo);

    the startinfo is

    System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();

    then I add Arguments (startInfo.Arguments), a FileName (startInfo.Filename), set the UseShellExecute to true (startInfo.UseShellExecute = true) ,set the CreateNoWindow to true (startInfo.CreateNoWindow) to hide the window, then set the RedirectStandardOutput to false during one try and to true in another try (startInfo.RedirectStandardOutput = false or true) and then I reset the UseShellExecute to false (startInfo.UseShellExecute = false). Finally I invoke the methode but it throws the exception described above. Does anyone of you have an idea? i checked all the paths and they are correct (meaning those I used during assigning the parameters). thanks. Stephan.

    M A 2 Replies Last reply
    0
    • S stephan_007

      hi everyone! i do have a problem, which occours on some machines but not on every machine: when using the process.start method, it throws the exception the path is invalid.

      System.Diagnostics.Process process = Process.Start(startInfo);

      the startinfo is

      System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();

      then I add Arguments (startInfo.Arguments), a FileName (startInfo.Filename), set the UseShellExecute to true (startInfo.UseShellExecute = true) ,set the CreateNoWindow to true (startInfo.CreateNoWindow) to hide the window, then set the RedirectStandardOutput to false during one try and to true in another try (startInfo.RedirectStandardOutput = false or true) and then I reset the UseShellExecute to false (startInfo.UseShellExecute = false). Finally I invoke the methode but it throws the exception described above. Does anyone of you have an idea? i checked all the paths and they are correct (meaning those I used during assigning the parameters). thanks. Stephan.

      M Offline
      M Offline
      Mogaambo
      wrote on last edited by
      #2

      Which Application you are running ? and, what is the path u given. post your code.

      S 1 Reply Last reply
      0
      • M Mogaambo

        Which Application you are running ? and, what is the path u given. post your code.

        S Offline
        S Offline
        stephan_007
        wrote on last edited by
        #3

        ....
        if (string.IsNullOrEmpty(AcrobatReaderPath))
        {
        //AcrobatReaderPath = @"C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe";
        AcrobatReaderPath = @"C:\Programme\Adobe\Reader 8.0\Reader\AcroRd32.exe";
        //AcrobatReaderPath = @"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe";
        }
        logger.Info("AcrobatReaderPath = " + AcrobatReaderPath);
        System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();
        logger.Info("1");
        startInfo.Arguments = "/h /t \"" + pdfFileName + "\" \"" + printerName + "\"";
        logger.Info("2");
        startInfo.FileName = AcrobatReaderPath;
        logger.Info("3");
        startInfo.UseShellExecute = true;
        logger.Info("4");
        startInfo.CreateNoWindow = true;
        logger.Info("5");
        startInfo.RedirectStandardOutput = false; // was true
        logger.Info("6");
        startInfo.UseShellExecute = false;
        logger.Info("7");
        System.Diagnostics.Process process = Process.Start(startInfo);
        logger.Info("8");
        ....

        I checked the acrobat path, it is correct. I checked the pdfFileName path, it is correct. I also checked the printername and this is correct as well. But when starting the process it throws the error message. What the code does: it prints a pdf file (located on harddisk) using the specified printer. As I said in my first posting, I tried it on different systems, there are some it works fine (no error message) but there are some which cause this message. And I have no clue why. the logging works well, so this should not be the problem! Stephan.

        M 1 Reply Last reply
        0
        • S stephan_007

          ....
          if (string.IsNullOrEmpty(AcrobatReaderPath))
          {
          //AcrobatReaderPath = @"C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe";
          AcrobatReaderPath = @"C:\Programme\Adobe\Reader 8.0\Reader\AcroRd32.exe";
          //AcrobatReaderPath = @"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe";
          }
          logger.Info("AcrobatReaderPath = " + AcrobatReaderPath);
          System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();
          logger.Info("1");
          startInfo.Arguments = "/h /t \"" + pdfFileName + "\" \"" + printerName + "\"";
          logger.Info("2");
          startInfo.FileName = AcrobatReaderPath;
          logger.Info("3");
          startInfo.UseShellExecute = true;
          logger.Info("4");
          startInfo.CreateNoWindow = true;
          logger.Info("5");
          startInfo.RedirectStandardOutput = false; // was true
          logger.Info("6");
          startInfo.UseShellExecute = false;
          logger.Info("7");
          System.Diagnostics.Process process = Process.Start(startInfo);
          logger.Info("8");
          ....

          I checked the acrobat path, it is correct. I checked the pdfFileName path, it is correct. I also checked the printername and this is correct as well. But when starting the process it throws the error message. What the code does: it prints a pdf file (located on harddisk) using the specified printer. As I said in my first posting, I tried it on different systems, there are some it works fine (no error message) but there are some which cause this message. And I have no clue why. the logging works well, so this should not be the problem! Stephan.

          M Offline
          M Offline
          Mogaambo
          wrote on last edited by
          #4

          the command which you are given , check that command manually whether it prints or not, Break your problem i 2-3 steps. First check whether acro reader is opening your file or not , if yes then check the full problem.

          S 1 Reply Last reply
          0
          • M Mogaambo

            the command which you are given , check that command manually whether it prints or not, Break your problem i 2-3 steps. First check whether acro reader is opening your file or not , if yes then check the full problem.

            S Offline
            S Offline
            stephan_007
            wrote on last edited by
            #5

            i already did this, and it works. but it does not work the way i programmed it. i will try to start just adobe and proceed step by step, maybe I will stumble into this error.

            S 1 Reply Last reply
            0
            • S stephan_007

              i already did this, and it works. but it does not work the way i programmed it. i will try to start just adobe and proceed step by step, maybe I will stumble into this error.

              S Offline
              S Offline
              stephan_007
              wrote on last edited by
              #6

              strange, the error is gone now, but this process should start the printing on the specified printer, but the program finishes with returncode ok but the file never reaches the printer. does this mean the processcall here doesn't throw any exception anymore but it doesn't really do what it should have done? does anyone of you have an idea? Stephan.

              S 1 Reply Last reply
              0
              • S stephan_007

                hi everyone! i do have a problem, which occours on some machines but not on every machine: when using the process.start method, it throws the exception the path is invalid.

                System.Diagnostics.Process process = Process.Start(startInfo);

                the startinfo is

                System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();

                then I add Arguments (startInfo.Arguments), a FileName (startInfo.Filename), set the UseShellExecute to true (startInfo.UseShellExecute = true) ,set the CreateNoWindow to true (startInfo.CreateNoWindow) to hide the window, then set the RedirectStandardOutput to false during one try and to true in another try (startInfo.RedirectStandardOutput = false or true) and then I reset the UseShellExecute to false (startInfo.UseShellExecute = false). Finally I invoke the methode but it throws the exception described above. Does anyone of you have an idea? i checked all the paths and they are correct (meaning those I used during assigning the parameters). thanks. Stephan.

                A Offline
                A Offline
                astanton1978
                wrote on last edited by
                #7

                Are you doing a "File.Exist(startInfo.Filename) = True" check before you are starting? Search for that file on the machine... If there are multiple copies, it may be trying to pull from a directory the %path%.

                1 Reply Last reply
                0
                • S stephan_007

                  strange, the error is gone now, but this process should start the printing on the specified printer, but the program finishes with returncode ok but the file never reaches the printer. does this mean the processcall here doesn't throw any exception anymore but it doesn't really do what it should have done? does anyone of you have an idea? Stephan.

                  S Offline
                  S Offline
                  stephan_007
                  wrote on last edited by
                  #8

                  when i set the process to start acrobate then it does, but it does not send the file to printer, as it is intended to. is there a way to debug this (meaning the process) to see, why no file is received by the printer queue?

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups