C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » File Operations »

Use of System.Diagnostics.Process


Posted Date: 18 Aug 2009    Resource Type: Code Snippets    Category: File Operations
Author: Shunmuganathan MMember Level: Diamond    
Rating: 1 out of 5Points: 7



Description :


We can run the exe files using the "System.Diagnostics.Process"

Following is the code for run the exe "WindowsMediaPlayer"


System.Diagnostics.Process MyProcess = new System.Diagnostics.Process();
MyProcess.StartInfo.WorkingDirectory = Request.MapPath("~/");
MyProcess.StartInfo.FileName = Request.MapPath("WindowsMediaPlayer.exe");
MyProcess.Start();


Code Explanation

1. Create An instance of the Process class responsible for starting the newly process.
2. Set the directory where the file resides
3. Set the filename name of the file you want to open
4. Start the process

We can open the application using the application exe



ProcessStartInfo MyProcessStartInfo = new ProcessStartInfo();
MyProcessStartInfo.FileName = @"c:\WINDOWS\system32\notepad.exe";
MyProcessStartInfo.Arguments = @"c:\MyText.txt";
Process.Start(processStartInfo);




In the above code we can open the MyText.txt file using the notepad.exe


Thanks
Nathan



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
System.Diagnostics.Process  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: List out the Image files in a Directory
Previous Resource: Count your subfolder
Return to Discussion Resource Index
Post New Resource
Category: File Operations


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use