473,770 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Diagnost ics.Process p = new System.Diagnost ics.Process();
p.StartInfo.Red irectStandardOu tput = false;
p.StartInfo.Fil eName = "GetData.ex e";
p.StartInfo.Arg uments = @" -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 2819
I would think that you would want RedirectStadard Output 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******** ******@TK2MSFTN GP03.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.Diagnost ics.Process p = new System.Diagnost ics.Process();
p.StartInfo.Red irectStandardOu tput = false;
p.StartInfo.Fil eName = "GetData.ex e";
p.StartInfo.Arg uments = @" -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.Use ShellExecute = 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.Diagnost ics.Process p = new System.Diagnost ics.Process();
p.StartInfo.Red irectStandardOu tput = false;
p.StartInfo.Fil eName = "GetData.ex e";
p.StartInfo.Arg uments = @" -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 RedirectStandar dOutput 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.Diagnost ics.Process p = new System.Diagnost ics.Process();
p.StartInfo.Red irectStandardOu tput = false;
p.StartInfo.Fil eName = "GetData.ex e";
p.StartInfo.Arg uments = @" -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
7477
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 point to some other process like, for example, the listener, or PMON, or whoever spawned it. thanks, Mike
2
2263
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 starts in my application and only terminates when my application is terminated. I want to write the output and the errors of this process to a seperate log file. In order to do this, I spawned two threads.
1
1818
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 something to do with process groups or threads and closeOnExec semantics (to speak in POSIX terms) is causing me a problem. I've got a windows service (let's call it "myService") that, among other things, does : onStart creates a TcpListener on a...
6
493
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 reboot the machine. Problem is that I am unsure of knowing exactly when the process has completed since any code placed after the proc.Start() method executes asynchronously. I am not certain if what I need to do is implement some sort of...
2
1679
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 consoneApplication's code.But if I run the WebForm1.cs's code at a WinApplication project.it can start the consoneApplication's process and run the consoneApplication's code. How to solve this question?
3
1277
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 already started, so I don't try to start it again, and how to check if the process is not running so i don't try to stop again? code: Public Class ProcEx Private p As Process Public Sub StartProcess()
22
3023
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 all the peak memory usage of all the processes (including aspnet_wp.exe), it goes up to no more than 1.5. How is that possible? Would anyone know please help? thanks!
2
6236
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 { mutex=new System.Threading.Mutex( true, mutexName, out createdNew)
10
2189
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 parameters before the callback method is called. Any ideas of how to do this or if it even matters? I did not know if calling the asynch process a new time kills the previous one or not. Thank you for your help. Susan
9
16149
by: SeC | last post by:
Hi. Is there any way to detect if application is being killed by 'End Process' via Task Manager ?
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.