Process.Start( ) syntax

G

Guest

The Process.Start( ) method below works correctly.

System.Diagnostics.Process.Start("c:\\program files\\adobe\\acrobat
6.0\\reader\\acrord32.exe",@"/t ""c:\exportfiles\d.pdf"" ""HP LaserJet 3300
Series PCL 6"" ""HP LaserJet 3300 Series PCL 6"" ""DOT4_001""");

I need to substitute a variable str1 for c:\exportfiles\d.pdf
programatically.

For example, String str1 = "c:\exportfiles\x.pdf";

I haven't been a to do so and would appreciate your help in doing so.
 
N

Nicholas Paldino [.NET/C# MVP]

mg,

When you use this:

String str1 = "c:\exportfiles\x.pdf";

It is trying to escape the \e and the \x. You can do one of two things,
doubling up the slashes, or using the @ literal identifier:

// Identical.
String str1 = "c:\\exportfiles\\x.pdf";
String str2 = @"c:\exportfiles\x.pdf";

Hope this helps.
 
G

Guest

I tried

String str = "c:\\exportfiles\\d.pdf";

System.Diagnostics.Process.Start("c:\\program files\\adobe\\acrobat
6.0\\reader\\acrord32.exe",@"/t " + str + " ""HP LaserJet 3300 Series PCL 6""
""HP LaserJet 3300 Series PCL 6"" ""DOT4_001""");

But, this isn't correct (produces many syntax errors). What can I do?



Nicholas Paldino said:
mg,

When you use this:

String str1 = "c:\exportfiles\x.pdf";

It is trying to escape the \e and the \x. You can do one of two things,
doubling up the slashes, or using the @ literal identifier:

// Identical.
String str1 = "c:\\exportfiles\\x.pdf";
String str2 = @"c:\exportfiles\x.pdf";

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mg said:
The Process.Start( ) method below works correctly.

System.Diagnostics.Process.Start("c:\\program files\\adobe\\acrobat
6.0\\reader\\acrord32.exe",@"/t ""c:\exportfiles\d.pdf"" ""HP LaserJet
3300
Series PCL 6"" ""HP LaserJet 3300 Series PCL 6"" ""DOT4_001""");

I need to substitute a variable str1 for c:\exportfiles\d.pdf
programatically.

For example, String str1 = "c:\exportfiles\x.pdf";

I haven't been a to do so and would appreciate your help in doing so.
 
N

Nicholas Paldino [.NET/C# MVP]

mg,

The string:

" ""HP LaserJet 3300 Series PCL 6"" ""HP LaserJet 3300 Series PCL 6""
""DOT4_001"""

Should be:

@" ""HP LaserJet 3300 Series PCL 6"" ""HP LaserJet 3300 Series PCL 6""
""DOT4_001"""


mg said:
I tried

String str = "c:\\exportfiles\\d.pdf";

System.Diagnostics.Process.Start("c:\\program files\\adobe\\acrobat
6.0\\reader\\acrord32.exe",@"/t " + str + " ""HP LaserJet 3300 Series PCL
6""
""HP LaserJet 3300 Series PCL 6"" ""DOT4_001""");

But, this isn't correct (produces many syntax errors). What can I do?



Nicholas Paldino said:
mg,

When you use this:

String str1 = "c:\exportfiles\x.pdf";

It is trying to escape the \e and the \x. You can do one of two
things,
doubling up the slashes, or using the @ literal identifier:

// Identical.
String str1 = "c:\\exportfiles\\x.pdf";
String str2 = @"c:\exportfiles\x.pdf";

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mg said:
The Process.Start( ) method below works correctly.

System.Diagnostics.Process.Start("c:\\program files\\adobe\\acrobat
6.0\\reader\\acrord32.exe",@"/t ""c:\exportfiles\d.pdf"" ""HP LaserJet
3300
Series PCL 6"" ""HP LaserJet 3300 Series PCL 6"" ""DOT4_001""");

I need to substitute a variable str1 for c:\exportfiles\d.pdf
programatically.

For example, String str1 = "c:\exportfiles\x.pdf";

I haven't been a to do so and would appreciate your help in doing so.
 
G

Guest

That did it. Thanks.

Nicholas Paldino said:
mg,

The string:

" ""HP LaserJet 3300 Series PCL 6"" ""HP LaserJet 3300 Series PCL 6""
""DOT4_001"""

Should be:

@" ""HP LaserJet 3300 Series PCL 6"" ""HP LaserJet 3300 Series PCL 6""
""DOT4_001"""


mg said:
I tried

String str = "c:\\exportfiles\\d.pdf";

System.Diagnostics.Process.Start("c:\\program files\\adobe\\acrobat
6.0\\reader\\acrord32.exe",@"/t " + str + " ""HP LaserJet 3300 Series PCL
6""
""HP LaserJet 3300 Series PCL 6"" ""DOT4_001""");

But, this isn't correct (produces many syntax errors). What can I do?



Nicholas Paldino said:
mg,

When you use this:

String str1 = "c:\exportfiles\x.pdf";

It is trying to escape the \e and the \x. You can do one of two
things,
doubling up the slashes, or using the @ literal identifier:

// Identical.
String str1 = "c:\\exportfiles\\x.pdf";
String str2 = @"c:\exportfiles\x.pdf";

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

The Process.Start( ) method below works correctly.

System.Diagnostics.Process.Start("c:\\program files\\adobe\\acrobat
6.0\\reader\\acrord32.exe",@"/t ""c:\exportfiles\d.pdf"" ""HP LaserJet
3300
Series PCL 6"" ""HP LaserJet 3300 Series PCL 6"" ""DOT4_001""");

I need to substitute a variable str1 for c:\exportfiles\d.pdf
programatically.

For example, String str1 = "c:\exportfiles\x.pdf";

I haven't been a to do so and would appreciate your help in doing so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top