passing arguments to the process C# and ASP.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • btreddy
    New Member
    • Oct 2008
    • 83

    #1

    passing arguments to the process C# and ASP.NET

    Hii all,
    im trying to start one process from a webpage and also trying to pass some arguments to that started process..but its not working .here is the code

    //CODE

    Code:
    string inputfile = @"pdfdoc.pdf";
            string outputfile = @"pdfdoc.swf";
                    
            Process pdf2swfprocess = new Process();
            pdf2swfprocess.StartInfo.UseShellExecute = false;
            pdf2swfprocess.StartInfo.RedirectStandardOutput = true;
            pdf2swfprocess.StartInfo.CreateNoWindow = true;
            pdf2swfprocess.EnableRaisingEvents = false;
            pdf2swfprocess.StartInfo.WorkingDirectory = @"C:\Documents and Settings\tirumalab\Desktop\PDF2SWF"; 
            pdf2swfprocess.StartInfo.RedirectStandardError = true;
            pdf2swfprocess.StartInfo.FileName = @"C:\Documents and Settings\tirumalab\Desktop\PDF2SWF\pdf2swf.exe";
            pdf2swfprocess.StartInfo.Arguments = inputfile + "-o" + outputfile;
             try
            {
                if (File.Exists(pdf2swfprocess.StartInfo.FileName))
                {
                    pdf2swfprocess.Start();
                    
                }
                else
                {
                    Response.Write("The file is not found at tht location ");
                }
                pdf2swfprocess.WaitForExit();
                pdf2swfprocess.Close();
            }
    Its not throwing any exceptions ..but the file(.swf )is not getting created.

    But the same thing is working in command line folderpath>pdf2 swf pdfdoc.pdf -o pdfswfdoc.swf.

    Plz..help me.
    Last edited by Frinavale; Dec 4 '08, 02:36 PM. Reason: added code tags
  • btreddy
    New Member
    • Oct 2008
    • 83

    #2
    how to pass arguments to the process in C# ?
    This is how it is in commandprompt. pdf2swf inputfile.pdf -o outputfile.swf.
    pdf2swf is the .exe that i need to start it in a process.

    Comment

    • shweta123
      Recognized Expert Contributor
      • Nov 2006
      • 692

      #3
      Hi,

      Please check that if inputfile and outputfile are present in the working directory path you have mentioned for
      pdf2swfprocess. StartInfo.Worki ngDirectory.

      The process is not starting because may be it is not getting specified arguments in the command prompt.

      Comment

      • btreddy
        New Member
        • Oct 2008
        • 83

        #4
        Hii thnks for the reply .i solved it.

        pdf2swfprocess. StartInfo.Argum ents = "pdfdoc.pdf "//inputfile// + "-o" + "pdfswf.swf "//outputfile//;

        thn its working.

        Thank you.
        Originally posted by shweta123
        Hi,

        Please check that if inputfile and outputfile are present in the working directory path you have mentioned for
        pdf2swfprocess. StartInfo.Worki ngDirectory.

        The process is not starting because may be it is not getting specified arguments in the command prompt.

        Comment

        Working...