473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Process Question

I have a EXE that spits out text in XML fomat.
I need to call this exe and have it write the XML to a file

I am using the following code:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = "GetData.exe";
p.StartInfo.Arguments = @" -listxml > c:\Output.xml";

p.Start();
My problem is that it never writes the output.xml
If I could rewrite the original application to spit out the data to a file I
would, but I am stuck using it as it stands.

Any ideas>
May 9 '06 #1
5 2770
I would think that you would want RedirectStadardOutput to true .. (then
just read the datastream and write it to a file.

The reason it is not working is that > is handled by the command prompt ..
(it redirects standard output to a file). If you wanted to use it you would
have to actually shell out to cmd and passing the program etc as the
arguments.
http://www.c-sharpcorner.com/Referen...ic.Process.asp
includes an example of reading the output of the program, it is just a
matter of writing the data to a filestream from there.

Cheers,

Greg Young
MVP - C#

Also
"Scott B" <sc************@milliman.com> wrote in message
news:Om**************@TK2MSFTNGP03.phx.gbl...
I have a EXE that spits out text in XML fomat.
I need to call this exe and have it write the XML to a file

I am using the following code:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = "GetData.exe";
p.StartInfo.Arguments = @" -listxml > c:\Output.xml";

p.Start();
My problem is that it never writes the output.xml
If I could rewrite the original application to spit out the data to a file
I would, but I am stuck using it as it stands.

Any ideas>

May 10 '06 #2
add this line to your code
p.StartInfo.UseShellExecute = false;

"Scott B" wrote:
I have a EXE that spits out text in XML fomat.
I need to call this exe and have it write the XML to a file

I am using the following code:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = "GetData.exe";
p.StartInfo.Arguments = @" -listxml > c:\Output.xml";

p.Start();
My problem is that it never writes the output.xml
If I could rewrite the original application to spit out the data to a file I
would, but I am stuck using it as it stands.

Any ideas>

May 10 '06 #3
In your arguments list, the "> C:\Output.xml" part is not recognized by
the GetData.exe. Those arguments are recognized only cmd.exe, the
command line, which is what you would normally run this program in.
That's why you did not get any output file created.

I agree with Greg Young, set RedirectStandardOutput to true and read
the data from the stream and output it to a file.

May 10 '06 #4
I just noticed that you also explained about the command prompt so
please ignore my post!!

May 10 '06 #5
Brilliant. I suppose I should have spent some more time delving into the
process class...

"Scott B"
I have a EXE that spits out text in XML fomat.
I need to call this exe and have it write the XML to a file

I am using the following code:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = "GetData.exe";
p.StartInfo.Arguments = @" -listxml > c:\Output.xml";

p.Start();
My problem is that it never writes the output.xml
If I could rewrite the original application to spit out the data to a file
I would, but I am stuck using it as it stands.

Any ideas>

May 10 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Michael J. Moore | last post by:
Is it the listener process, or some other Oracle process. Also, on a UNIX system, when you do "ps -ef" to see your processes, the PPID points back to a process named "init". Why does the PPID not...
2
by: mwazir | last post by:
Hi all, I have reposted this question from dotnet.general as I have been advised that this is a more appropriate forum for this question. Apologies for the repost. I have a process thats...
1
by: Doug Wyatt | last post by:
So I'll preface this with the fact that I'm a UNIX developer by training and have just recently gotten in to C# development on Windows. I'm basically running in to a problem whereby I suspect...
6
by: A | last post by:
Hi all, This is sort of a newbie question. I have a method that creates a process which in turn installs MSDE. Basically, after I start the process I need to wait until it is complete and then...
2
by: ca___t | last post by:
Hi there : I want to start a consoneApplication using process.start method at web application server side.I have a question at this.Why the consoneApplication's process is start but not run...
3
by: Nikolay Petrov | last post by:
I have a class which starts a process and redirects it's output and input. My class have a method which starts the process and another which stops it. How can I check if the process have been...
22
by: Zen | last post by:
Hi, My production machine has 2G of memory, when aspnet_wp.exe goes up to about ~1.2G of memory usage, I start get out-of-memory exception. Other processes don't use as much memory and I added...
2
by: tony.newsgrps | last post by:
Hi there, I'm trying to understand the impact of killing a process that owns a system mutex (used to ensure there is only 1 instance of my program running) Here is my code pretty much: try...
10
by: Susan | last post by:
I have a process that takes a while to run so I have it running asynchronously so that the user can continue working. My question is that I want to killl the process if the user changes the search...
9
by: SeC | last post by:
Hi. Is there any way to detect if application is being killed by 'End Process' via Task Manager ?
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.